mysql> SELECT DateDiff('2008-12-29','2008-12-30') AS DiffDate; +----------+ | DiffDate | +----------+ | -1 | +----------+ 1 row in set (0.00 sec) mysql> SELECT DateDiff('2008-12-29','2008-12-20') AS DiffDate; +----------+ | DiffDate | +----------+ | 9 | +----------+ 1 row in set (0.00 sec)
DATEDIFF() 函数返回两个日期之间的天数。
DATEDIFF(date1,date2)
date1 和 date2 参数是合法的日期或日期/时间表达式。
注释:只有值的日期部分参与计算。