ADDDATE
Adds a time interval or a number of days to a date.
MySQL 8.4
ADDDATE(date, INTERVAL expr unit | days)- a | bone of the options
- date
- Source date or datetimeDATE
- INTERVAL expr unit
- Interval to add, for example INTERVAL 7 DAY
- expr
- How many units to add
- unit
- Interval unitKeywordMICROSECONDSECONDMINUTEHOURDAYWEEKMONTHQUARTERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTH
- days
- Number of days, a short form instead of INTERVALINT
Return value
A date if days or larger units are added to a date, otherwise a datetime; if the month has no such day, its last day is used
Examples
Ten days added to a date
MySQL 8.4
SELECT ADDDATE('2022-06-16', INTERVAL 10 DAY) AS new_date;Short form with days
MySQL 8.4
SELECT ADDDATE('2022-06-16', 10) AS new_date;Compound interval unit
MySQL 8.4
SELECT ADDDATE(
'2022-06-16 10:00:00',
INTERVAL '1:30' HOUR_MINUTE
) AS new_date;Details
Instead of the function, you can add or subtract an interval with an operator: date + INTERVAL 7 DAY. PostgreSQL has no such function: a date is shifted with the same operator, but the interval is written as a string: date + INTERVAL '7 days'.