MySQL 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)
當第二個參數的使用天的形式調用,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)