DATE_ADD
adding intervals to dates.
Overview
DATE_ADD(date, INTERVAL value unit) adds an interval in the requested unit. Day arithmetic and month arithmetic follow different calendar rules, while month ends, leap years, and DATETIME versus TIMESTAMP time-zone behavior require separate checks. For filtering, calculate boundary constants rather than wrapping every row's column when possible.
Basic syntax
SELECT DATE_ADD(created_at, INTERVAL 7 DAY) FROM orders;
Examples
DATE_ADD example
The example adds seven days to each order timestamp for a due-date calculation; real use must also define the time type and time zone.
Sample table
orders| created_at |
|---|
| 2026-01-03 |
| 2026-01-08 |
| 2026-02-02 |
| 2026-02-15 |
Run result
| date(created_at, '+7 day') |
|---|
| 2026-01-10 |
| 2026-01-15 |
| 2026-02-09 |
| 2026-02-22 |
Common issues
Months have different lengths, so the database adjusts according to its rules. Test settlement logic with dates on the 28th through 31st.
Not completely. TIMESTAMP may be affected by the session time zone, so cross-zone systems need explicit storage and display rules.
On large tables, calculate the boundary first and compare the column directly to preserve the opportunity for index use.
Tags
Was this explanation clear?
Thanks. This feedback will inform the next content review.