MySQL compare now() (only date, not time) with a datetime field

前端 未结 2 1422
心在旅途
心在旅途 2020-12-08 12:57

I have a duedate column(datetime format) that specifies the due date of a ticket, now i need to get \'Due today\' tickets base on the comparison be

相关标签:
2条回答
  • 2020-12-08 13:19

    Compare date only instead of date + time (NOW) with:

    CURDATE()
    
    0 讨论(0)
  • 2020-12-08 13:41

    Use DATE(NOW()) to compare dates

    DATE(NOW()) will give you the date part of current date and DATE(duedate) will give you the date part of the due date. then you can easily compare the dates

    So you can compare it like

    DATE(NOW()) = DATE(duedate)
    

    OR

    DATE(duedate) = CURDATE() 
    

    See here

    0 讨论(0)
提交回复
热议问题