开发者

How can I find the difference between two dates in MySQL?

开发者 https://www.devze.com 2023-02-25 05:51 出处:网络
How can I find the difference between 开发者_JS百科two dates in MySQL?DATEDIFF returns the difference in days between two dates:

How can I find the difference between 开发者_JS百科two dates in MySQL?


DATEDIFF returns the difference in days between two dates:

http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_datediff


mysql> select current_date()>'2011-01-01 12:01:01';
+--------------------------------------+
| current_date()>'2011-01-01 12:01:01' |
+--------------------------------------+
|                                    1 |
+--------------------------------------+
1 row in set (0.00 sec)

mysql> select '2011-01-01 12:01:01' > current_date();
+----------------------------------------+
| '2011-01-01 12:01:01' > current_date() |
+----------------------------------------+
|                                      0 |
+----------------------------------------+
1 row in set (0.00 sec)

mysql> 


learn DATEDIFF

eg :     SELECT DATEDIFF('2007-12-31 23:59:59','2007-12-30');
0

精彩评论

暂无评论...
验证码 换一张
取 消