This tutorial explains how to use the MySQL DATE_ADD function with syntax and examples.
The MySQL DATE_ADD function returns a date after which a certain time/date interval has been added.
The syntax for the DATE_ADD function in MySQL is:
The date to which the interval should be added.
The value of the time/date interval that you wish to add. You can specify positive and negative values for this parameter.
The unit type of the interval such as DAY, MONTH, MINUTE, HOUR, and so on. It can be one of the following:
unit | Compatibility |
---|---|
MICROSECOND | 4.1.1+ |
SECOND | 3.2.3+ |
MINUTE | 3.2.3+ |
HOUR | 3.2.3+ |
DAY | 3.2.3+ |
WEEK | 5+ |
MONTH | 3.2.3+ |
QUARTER | 5+ |
YEAR | 3.2.3+ |
SECOND_MICROSECOND | 4.1.1+ |
MINUTE_MICROSECOND | 4.1.1+ |
MINUTE_SECOND | 4.1.1+ |
HOUR_MICROSECOND | 4.1.1+ |
HOUR_SECOND | 4.1.1+ |
HOUR_MINUTE | 3.2.3+ |
DAY_MICROSECOND | 4.1.1+ |
DAY_SECOND | 3.2.3+ |
DAY_MINUTE | 3.2.3+ |
DAY_HOUR | 3.2.3+ |
YEAR_MONTH | 3.2.3+ |
The DATE_ADD function can be used in the following versions of MySQL:
Let's look at some MySQL DATE_ADD function examples and explore how to use the DATE_ADD function in MySQL.
For example: