// dialect comparison

Add days to a date in SQL Server, PostgreSQL, MySQL, SQLite and Oracle

Five engines, five spellings of 'a week from today'.

Filed under Types & casting

The verdict

PostgreSQL and Oracle read like arithmetic, MySQL and SQL Server read like function calls, and SQLite reads like a tiny language of modifiers. None of it ports without rewriting.

Where they differ

Adding days is the most common date arithmetic, and it is the clearest window into each engine's model: real date types add numbers directly, while text-based or function-based engines need a dedicated call.

How each engine writes it

SQL Server

SELECT DATEADD(DAY, 7, '2026-11-20');

No + on DATE values: DATEADD covers every unit and keeps the input's type. A string literal is read as datetime, so this returns 2026-11-27 00:00:00.000.

PostgreSQL

SELECT DATE '2026-11-20' + 7;

An integer adds days to a date; add INTERVAL '7 days' to a timestamp instead.

MySQL

SELECT DATE_ADD('2026-11-20', INTERVAL 7 DAY);

INTERVAL n DAY is the general mechanism. '2026-11-20' + 7 coerces the string to the number 2026 and returns 2033.

SQLite

SELECT DATE('2026-11-20', '+7 days');

Dates are text: modifiers like '+7 days' chain after the base time, e.g. DATE('now', '+7 days').

Oracle

SELECT DATE '2026-11-20' + 7 FROM dual;

Adding a number to a DATE adds that many days; fractions add time (1/24 is one hour).

Questions that come up

Can I add hours and minutes too?

Yes: DATEADD(HOUR, ...) in SQL Server, INTERVAL '7 hours' in PostgreSQL, INTERVAL 7 HOUR in MySQL, '+7 hours' in SQLite, and fractions of a day in Oracle (DATE + 4.5/24).

Why does MySQL '2026-11-20' + 7 return a number?

In numeric context MySQL reads the string's leading number, 2026, and returns 2033 with a warning. A real DATE fares no better: DATE '2026-11-20' + 7 is 20261127. Date arithmetic goes through DATE_ADD/DATE_SUB or + INTERVAL.

Does adding days cross DST correctly?

PostgreSQL's timestamptz does: adding INTERVAL '1 day' across a DST change keeps the wall-clock time, while INTERVAL '24 hours' adds exactly 24 hours. SQL Server's DATEADD on datetimeoffset keeps the offset fixed, and naive date and timestamp types everywhere just add calendar days.

Keep reading

// write it once, run it anywhere

Switch engines without relearning SQL

SQLly is a native SQL workbench for macOS, Windows and Linux. Its formatter and plan viewer work in all five dialects.