This tutorial explains how to use the MySQL ADDDATE function with syntax and examples.
The MySQL ADDDATE function returns a date after which a certain time/date interval has been added.
The syntax for the ADDDATE function in MySQL is:
OR
The date to which the interval should be added.
The number of days to add to date (second syntax).
The value of the time/date interval that you wish to add. You can specify positive and negative values for this parameter (first syntax).
The unit type of the interval such as DAY, MONTH, MINUTE, HOUR, and so on. It can be one of the following (first syntax):
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 ADDDATE function can be used in the following versions of MySQL:
Let's look at some MySQL ADDDATE function examples and explore how to use the ADDDATE function in MySQL.
For example: