復制代碼 代碼如下: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)