复制代码 代码如下:
ADDDATE(date,INTERVAL expr unit), ADDDATE(expr,days)
当被调用的第二个参数的区间形式,ADDDATE()是DATE_ADD()的同义词。相关功能SUBDATE()是DATE_SUB()的代名词。对于区间上的单元参数的详细信息,请参阅DATE_ADD()的说明。
mysql> SELECT DATE_ADD('1998-01-02', INTERVAL 31 DAY); +---------------------------------------------------------+ | DATE_ADD('1998-01-02', INTERVAL 31 DAY) | +---------------------------------------------------------+ | 1998-02-02 | +---------------------------------------------------------+ 1 row in set (0.00 sec) mysql> SELECT ADDDATE('1998-01-02', INTERVAL 31 DAY); +---------------------------------------------------------+ | ADDDATE('1998-01-02', INTERVAL 31 DAY) | +---------------------------------------------------------+ | 1998-02-02 | +---------------------------------------------------------+ 1 row in set (0.00 sec)
当被调用的第二个参数的形式,MySQL的把它作为一个整数天数添加到expr。
mysql> SELECT ADDDATE('1998-01-02', 31); +---------------------------------------------------------+ | DATE_ADD('1998-01-02', INTERVAL 31 DAY) | +---------------------------------------------------------+ | 1998-02-02 | +---------------------------------------------------------+ 1 row in set (0.00 sec)