DATE_ADD()
Adds an interval to a date or timestamp.
Description
DATE_ADD shifts a date or timestamp forward by a given interval — add a day,
a month, a year, and so on. It's the safe, calendar-aware way to move dates
around (handling month lengths and leap years) instead of adding raw numbers.
Syntax
DATE_ADD(date, INTERVAL '1 month')
DATE_ADD(date, INTERVAL '7 days')Parameters
| Name | Description | Optional |
|---|---|---|
| date | The starting date/timestamp. | No |
| interval | The interval to add (e.g. INTERVAL '1 year'). | No |
Return Type
Returns the same type as the input (DATE stays DATE, TIMESTAMP stays TIMESTAMP).
Examples
Employees & Departments
Loading database engine...
Employees & Departments
Loading database engine...
DATE_ADD vs subtraction
To subtract, use DATE_SUB or a negative interval: DATE_ADD(date, INTERVAL '-1 month').
Common Mistakes
- Adding raw numbers.
hire_date + 30is not the same as+ INTERVAL '30 days'; use intervals for correct calendar math. - Leap years. Intervals handle Feb 29 correctly; raw arithmetic doesn't.
- Type mismatch. Mixing a DATE with a timestamp interval can change the result type.
Related Functions
See also: DATE_SUB, DATEDIFF, DATE_TRUNC.