Date Addition / Subtraction
SQL · Date Functionssyntax
-- PostgreSQL
date + INTERVAL 'n unit'
-- MySQL
DATE_ADD(date, INTERVAL n unit)
-- ANSI
date + INTERVAL 'n' unitexample
-- PostgreSQL
SELECT
order_date,
order_date + INTERVAL '30 days' AS due_date,
order_date - INTERVAL '1 year' AS year_ago
FROM orders;
-- MySQL
SELECT
order_date,
DATE_ADD(order_date, INTERVAL 30 DAY) AS due_date
FROM orders;output
-- order_date | due_date | year_ago
-- 2025-10-15 | 2025-11-14 | 2024-10-15Note Interval units: YEAR, MONTH, DAY, HOUR, MINUTE, SECOND. Adding months is tricky — Jan 31 + 1 month may yield Feb 28 or Mar 3 depending on the database. PostgreSQL truncates to end of month; MySQL may overflow.