This article describes how to use the ADDDATE () function in MySQL. it is the basic knowledge in MySQL getting started. For more information, see the following code:
ADDDATE (date, INTERVAL expr unit), ADDDATE (expr, days)
When the second parameter is called in the interval format, ADDDATE () is the synonym of DATE_ADD. SUBDATE () is synonymous with DATE_SUB. For details about the unit parameters in the interval, see the description of 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)
When the second parameter is called, MySQL adds it as an integer number of days to 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)