How to Add Dates in MySQL
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
Adding dates in MySQL is a common task for database management, often requiring precision and understanding of MySQL’s date and time functions. The DATE_ADD function, in particular, is essential for manipulating and calculating dates.
The DATE_ADD function in MySQL is used to add a specified time interval to a date.
DATE_ADD(date, INTERVAL expr unit)
date: The starting dateexpr: The value of the time interval to addunit: The unit of the time interval (e.g., DAY, MONTH, YEAR)SELECT DATE_ADD('2023-01-01', INTERVAL 10 DAY);
This query adds 10 days to January 1, 2023.
SELECT DATE_ADD('2023-01-01', INTERVAL 2 MONTH);
This adds 2 months to January 1, 2023.
SELECT DATE_ADD('2023-01-01', INTERVAL 1 YEAR);
This example adds 1 year to January 1, 2023.
SELECT DATE_ADD(CURDATE(), INTERVAL 15 DAY);
Adds 15 days to the current date.
SELECT DATE_ADD('2023-01-01', INTERVAL -3 DAY);
Subtracts 3 days from January 1, 2023.
SELECT DATE_ADD('2023-01-01 08:30:00', INTERVAL '2:15:30' HOUR_SECOND);
Adds 2 hours, 15 minutes, and 30 seconds to the specified datetime.
SELECT DATE_ADD('2023-01-01', INTERVAL '1-2' YEAR_MONTH);
Adds 1 year and 2 months to January 1, 2023.
UPDATE orders
SET delivery_date = DATE_ADD(order_date, INTERVAL 7 DAY)
WHERE order_id = 1001;
Sets the delivery date to 7 days after the order date for a specific order.
DATE_SUB function for more intuitive date subtraction.Written by
Senior Engineer at Basedash
Robert Cooper is a senior engineer at Basedash who builds full-stack product systems across SQL data infrastructure, APIs, and frontend architecture. His work focuses on application performance, developer velocity, and reliable self-hosted workflows that make data operations easier for teams at scale.
Basedash lets you build charts, dashboards, and reports in seconds using all your data.