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 between now()
with duedate
. i.e 2010-04-29 02:00
vs 2010-04-29 10:00
would return true in this matter.
我有一个duedate列(datetime格式),它指定了一张票的到期日,现在我需要根据now()与duedate之间的比较获得“due today”票。我。e 2010-04-29 02:00 vs 2010-04-29 10:00在这件事上将返回真实。
2 个解决方案
#1
100
Use DATE(NOW())
to compare dates
使用DATE(NOW()来比较日期
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
日期(现在)会给你日期部分的当前日期和日期(duedate)会给你日期部分的到期日期。然后你可以很容易地比较日期
So you can compare it like
你可以这样比较
DATE(NOW()) = DATE(duedate)
OR
或
DATE(duedate) = CURDATE()
See here
在这里看到的
#2
11
Compare date only instead of date + time (NOW) with:
只比较日期而不是日期+时间(现在)与:
CURDATE()
#1
100
Use DATE(NOW())
to compare dates
使用DATE(NOW()来比较日期
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
日期(现在)会给你日期部分的当前日期和日期(duedate)会给你日期部分的到期日期。然后你可以很容易地比较日期
So you can compare it like
你可以这样比较
DATE(NOW()) = DATE(duedate)
OR
或
DATE(duedate) = CURDATE()
See here
在这里看到的
#2
11
Compare date only instead of date + time (NOW) with:
只比较日期而不是日期+时间(现在)与:
CURDATE()