SQL Server
SELECT DATEADD(MONTH, 3, '2026-11-20');
Adds calendar months and clamps: DATEADD(MONTH, 1, '2026-01-31') is 2026-02-28. It keeps the day number otherwise, so Feb 28 + 1 month is Mar 28.
Jan 31 plus one month is Feb 28 in four engines, Mar 3 in SQLite, and an error with Oracle's INTERVAL form.
Filed under Types & casting
SQL Server, PostgreSQL, MySQL and Oracle's ADD_MONTHS clamp Jan 31 + 1 month to Feb 28/29. SQLite rolls into March unless you add 'floor', and Oracle's INTERVAL form errors. ADD_MONTHS also snaps month-end inputs to month ends, so test month-end dates explicitly.
Adding months is trickier than adding days because month lengths differ. Each engine has a rule for what Jan 31 + 1 month means, and they do not all agree.
SELECT DATEADD(MONTH, 3, '2026-11-20');
Adds calendar months and clamps: DATEADD(MONTH, 1, '2026-01-31') is 2026-02-28. It keeps the day number otherwise, so Feb 28 + 1 month is Mar 28.
SELECT DATE '2026-11-20' + INTERVAL '3 months';
Jan 31 + 1 month gives Feb 28: interval arithmetic clamps to the end of the target month.
SELECT DATE_ADD('2026-11-20', INTERVAL 3 MONTH);
Clamps to month end: Jan 31 + 1 month is Feb 28/29.
SELECT DATE('2026-11-20', '+3 months');
Does not clamp: '+1 month' on 2026-01-31 builds Feb 31, which normalizes forward to 2026-03-03. SQLite 3.46+ accepts a 'floor' modifier, DATE(d, '+1 month', 'floor'), that clamps to Feb 28 instead.
SELECT ADD_MONTHS(DATE '2026-11-20', 3) FROM dual;
ADD_MONTHS clamps, and a month-end input always maps to the target month's last day (Feb 28 + 1 month is Mar 31). DATE '2026-01-31' + INTERVAL '1' MONTH raises ORA-01839 instead.
SQLite adds 1 to the month field and keeps day 31. Feb 31 does not exist, so it normalizes forward to Mar 3. On 3.46 and later, append the 'floor' modifier to clamp to Feb 28 instead.
SYSDATE + INTERVAL '1' MONTH raises ORA-01839 on a date whose day does not exist in the target month. ADD_MONTHS handles it by clamping, so most shops standardize on ADD_MONTHS.
SQL Server, PostgreSQL and MySQL clamp to the last day of the target month and otherwise keep the day number. Oracle's ADD_MONTHS also maps any month-end input to a month end, so ADD_MONTHS(DATE '2026-02-28', 1) is Mar 31 while DATEADD gives Mar 28. SQLite is the outlier that overflows.
Five engines, five spellings of 'a week from today'.
A staple of reporting SQL, computed five different ways.
Three engines have a named function; PostgreSQL and SQLite make you derive it.
SQLly is a native SQL workbench for macOS, Windows and Linux. Its formatter and plan viewer work in all five dialects.