expr is an expression specifying the interval value.
expr is a string.
expr may start with a '-' for negative intervals.
unit is a keyword indicating the units in which the expression should be interpreted.
The following table shows the expected form of the expr argument for each unit value.
14.10.DATE_ADD |
| 14.10.1. | DATE_ADD(date,INTERVAL expr unit) |
| 14.10.2. | DATE_ADD(curdate(), INTERVAL 1 MICROSECOND); |
| 14.10.3. | DATE_ADD(curdate(), INTERVAL 1 MINUTE); |
| 14.10.4. | DATE_ADD(curdate(), INTERVAL 1 HOUR); |
| 14.10.5. | DATE_ADD(curdate(), INTERVAL 1 DAY); |
| 14.10.6. | DATE_ADD(curdate(), INTERVAL 1 WEEK); |
| 14.10.7. | DATE_ADD(curdate(), INTERVAL 1 MONTH); |
| 14.10.8. | DATE_ADD(curdate(), INTERVAL 1 QUARTER); |
| 14.10.9. | DATE_ADD(curdate(), INTERVAL 1 YEAR); |
| 14.10.10. | DATE_ADD(curdate(), INTERVAL 1.1 SECOND_MICROSECOND) |
| 14.10.11. | DATE_ADD(curdate(), INTERVAL 1 SECOND); |
| 14.10.12. | DATE_ADD(curdate(), INTERVAL 1.1 SECOND); |
| 14.10.13. | DATE_ADD(curdate(), INTERVAL 1.1 MINUTE_MICROSECOND); |
| 14.10.14. | DATE_ADD(curdate(), INTERVAL 1.1 MINUTE_SECOND); |
| 14.10.15. | DATE_ADD(curdate(), INTERVAL 1.1 HOUR_MICROSECOND); |
| 14.10.16. | DATE_ADD(curdate(), INTERVAL 1.1 HOUR_SECOND); |
| 14.10.17. | DATE_ADD(curdate(), INTERVAL '1:1:1' HOUR_SECOND); |
| 14.10.18. | DATE_ADD(curdate(), INTERVAL 1.1 HOUR_MINUTE); (with dot) |
| 14.10.19. | DATE_ADD(curdate(), INTERVAL '1:1' HOUR_MINUTE); |
| 14.10.20. | DATE_ADD(curdate(), INTERVAL 1.1 DAY_MICROSECOND); |
| 14.10.21. | DATE_ADD(curdate(), INTERVAL '1 1:1:1' DAY_SECOND); |
| 14.10.22. | DATE_ADD(curdate(), INTERVAL '1 1:1' DAY_MINUTE); |
| 14.10.23. | DATE_ADD(curdate(), INTERVAL '1 1' DAY_HOUR);(wihtout :) |
| 14.10.24. | DATE_ADD(curdate(), INTERVAL 1.1 SECOND_MICROSECOND); (with dot) |
| 14.10.25. | DATE_ADD(curdate(), INTERVAL '1-1' YEAR_MONTH); (with minus sign) |
| 14.10.26. | DATE_ADD(curdate(), INTERVAL '1.1' YEAR_MONTH); (with dot) |
| 14.10.27. | Adding one day to a date: SELECT DATE_ADD('2006-05-01',INTERVAL 1 DAY); |
| 14.10.28. | Adding one month to a date: SELECT DATE_ADD('2006-05-01',INTERVAL 1 MONTH); |
| 14.10.29. | Adding one year to a date: SELECT DATE_ADD('2006-05-01',INTERVAL 1 YEAR); |
| 14.10.30. | Adding one month to start date |
| 14.10.31. | SELECT DATE_ADD('1997-12-31 23:59:59', 1 SECOND); |
| 14.10.32. | SELECT DATE_ADD('1997-12-31 23:59:59', 1 DAY); |
| 14.10.33. | SELECT DATE_ADD('1997-12-31 23:59:59', '1:1' MINUTE_SECOND); |
| 14.10.34. | SELECT DATE_SUB('1998-01-01 00:00:00', '1 1:1:1' DAY_SECOND); |
| 14.10.35. | SELECT DATE_ADD('1998-01-01 00:00:00', '-1 10' DAY_HOUR); |
| 14.10.36. | SELECT DATE_SUB('1998-01-02', INTERVAL 31 DAY); |
| 14.10.37. | SELECT DATE_ADD('1992-12-31 23:59:59.000002', '1.999999' SECOND_MICROSECOND); |
| 14.10.38. | If you add to or subtract from a date value something that contains a time part, the result is automatically converted to a datetime value. |
| 14.10.39. | SELECT DATE_ADD('1999-01-01', INTERVAL 1 HOUR); |
| 14.10.40. | If the resulting date has a day that is larger than the maximum day for the new month, the day is adjusted to the maximum days in the new month. |
| 14.10.41. | Date arithmetic operations require complete dates |
| 14.10.42. | SELECT '2005-03-32' + INTERVAL 1 MONTH; |