以下摘自 MySQL 5.1 Reference ManualDATEDIFF(expr1,expr2) DATEDIFF() returns expr1 – expr2 expressed as a value in days from one date to the other. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation.
== 思想重于技巧 ==
此外还有DATE_SUB() DATEDIFF()(v4.1.1) TIMEDIFF()(v4.1.1) 详见 MySQL 5.1 Reference Manual
INTERVAL "1 1:1:1" DAY_SECOND);
-> 1997-12-30 22:58:59
mysql> SELECT DATE_SUB("1998-01-02", INTERVAL 31 DAY);
-> 1997-12-02
DATEDIFF()(v4.1.1)
TIMEDIFF()(v4.1.1)
详见 MySQL 5.1 Reference Manual