Search code examples
mysqlsqlmetabase

Replacing now () with current date and custom time


I'd like to replace now() with the current date and a custom time for example: 7/28/2021 8:00 AM

(select count(*) from students where exams.id=students.exam_id and students.exam_id=exams.id 
and end_time <> ''and bb_user_id is not null and test_status<>1 and
review_end is null and (exam_end + interval 2 day) > now() and exam_end < now()) as current

Solution

  • You can set the time on the current date using addtime():

    select addtime(cast(current_date as datetime), time('08:00:00'))
    

    Note that the first argument needs to be a datetime, so addtime(current_date, time('08:00:00')).