DATE_ADD() and DATE_SUB() add and subtract time to a date.
Syntax:
DATE_ADD(date,INTERVAL expr type) DATE_SUB(date,INTERVAL expr type)
The date - is a standard DATE or DATETIME value.
INTERVAL is followed by the time period (expr).
Finally what type period it is (Month, Day, Year etc).
mysql> mysql> SELECT DATE_ADD(CURDATE(), INTERVAL 60 DAY); +--------------------------------------+ | DATE_ADD(CURDATE(), INTERVAL 60 DAY) | +--------------------------------------+ | 2007-09-19 | +--------------------------------------+ 1 row in set (0.00 sec) mysql> mysql>
14.1.Introduction | ||||
14.1.1. | Date and Time Functions | |||
14.1.2. | Extraction Functions | |||
14.1.3. | Changing Date Values | |||
14.1.4. | Getting Day Information | |||
14.1.5. | Getting Names for Months and Days | |||
14.1.6. | Extracting Years, Quarters, Months, and Weeks | |||
14.1.7. | Current Date and Time | |||
14.1.8. | Days Since 1 A.D. | |||
14.1.9. | Seconds Since the Beginning of the Day |