SQL ADDDATE()函数
ADDDATE(date,INTERVAL expr unit), ADDDATE(expr,days)
当第二个参数INTERVAL形式调用,ADDDATE() 是DATE_ADD()的同义词。 相关函数SUBDATE()是DATE_SUB()同义词。 有关INTERVAL 参数信息,请参阅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)
当第二个参数days 的形式调用时,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)