一、两个日期间隔天数,使用datediff()函数
例:
mysql> select datediff(now(),'20160401');
+----------------------------+
| datediff(now(),'20160401') |
+----------------------------+
| 4 |
+----------------------------+
1 row in set (0.00 sec)
二、两个日期精确间隔,使用timediff
mysql> select timediff(now(),'2016-04-04 18:10:10');
+---------------------------------------+
| timediff(now(),'2016-04-04 18:10:10') |
+---------------------------------------+
| 15:41:28 |
+---------------------------------------+
1 row in set (0.00 sec)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29989552/viewspace-2075317/,如需转载,请注明出处,否则将追究法律责任。