Lesson

MySQL ADDDATE() Function

10 min reading
Free Course

MySQL ADDDATE(): Shift Dates Forward by Days or Intervals

The ADDDATE() function moves a DATE or DATETIME value forward by a specified interval or integer day count. Unlike DATE_ADD(), ADDDATE() offers a compact two-argument form when you only need to add whole days.

Teams use ADDDATE() to calculate invoice due dates, shipping windows, and trial expiration dates directly in SQL queries.

Syntax

ADDDATE() accepts either a standard INTERVAL clause or a plain integer representing days:

ADDDATE(date_value, INTERVAL expr unit)
ADDDATE(date_value, days)
  • date_value: A DATE, DATETIME, or valid date string such as '2026-05-12'.
  • INTERVAL expr unit: Works identically to DATE_ADD(), supporting units like DAY, WEEK, MONTH, YEAR, and HOUR.
  • days: An integer value added as days. Negative numbers move the date backward.

Practical Example

Suppose your fulfillment team calculates an estimated delivery date by adding 5 days to each row in demo_orders, alongside a 30-day return deadline.

SELECT
    order_id,
    customer_id,
    order_date,
    ADDDATE(order_date, 5) AS estimated_delivery,
    ADDDATE(order_date, INTERVAL 1 MONTH) AS return_deadline
FROM demo_orders
WHERE order_id IN (101, 102, 103);
order_id customer_id order_date estimated_delivery return_deadline
101 14 2026-01-31 2026-02-05 2026-02-28
102 29 2026-03-14 2026-03-19 2026-04-14
103 42 2026-05-01 2026-05-06 2026-06-01

Notice row 101: adding INTERVAL 1 MONTH to 2026-01-31 clamps safely to 2026-02-28 instead of overflowing into March.

Common Mistakes & NULL Behavior

Watch out for these subtle issues when calling ADDDATE() in production queries:

  • Invalid calendar dates return NULL: Passing '2026-02-30' or '2026-04-31' makes ADDDATE() return NULL, even with a valid day offset.
  • Any NULL input yields NULL: If either the date column or the day offset evaluates to NULL, the output becomes NULL.
  • Mixing up time units: Passing an integer shorthand like ADDDATE(order_date, 2) always means 2 days, never 2 hours or 2 months.
  • Unindexed WHERE comparisons: Calling ADDDATE(order_date, 7) > CURDATE() prevents MySQL from using an index on order_date. Rewrite it as order_date > SUBDATE(CURDATE(), 7).

Frequently Asked Questions

What is the difference between ADDDATE() and DATE_ADD() in MySQL?

When you write INTERVAL expr unit, ADDDATE() and DATE_ADD() behave identically. However, ADDDATE() also supports the shorthand ADDDATE(date, days) without the INTERVAL keyword, while DATE_ADD() throws a syntax error without INTERVAL.

Can ADDDATE() subtract days from a date?

Yes. Pass a negative integer such as ADDDATE('2026-05-12', -7) or a negative interval like INTERVAL -7 DAY. Both return '2026-05-05'.

Does ADDDATE() preserve the time component of a DATETIME?

Yes. Adding days or months to a DATETIME keeps the original HH:MM:SS intact, and adding HOUR or MINUTE updates both date and time.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Try it Yourself

Experiment with the code from this lesson in our interactive playground.

Open Playground
MySQL Topic Hub

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum