PHP开发教程

MySQL timestampdiff()函数

TIMESTAMPDIFF(unit,datetime_expr1,datetime_expr2)

返回日期或日期时间表达式datetime_expr1 和 datetime_expr2 之间的整数差,结果的单位是由该单元参数给出。单位的合法值的说明与在TIMESTAMPADD()函数列出相同。

mysql> SELECT TIMESTAMPDIFF(MONTH,'2003-02-01','2003-05-01');
+---------------------------------------------------------+
| TIMESTAMPDIFF(MONTH,'2003-02-01','2003-05-01')          |
+---------------------------------------------------------+
| 3                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)


Powered by PHP二次开发 ©2008-2017