DATE_ADD And DATE_SUBTRACT Across DST Shifts

Step timestamptz across spring-forward and fall-back DST boundaries in an explicit target zone using PostgreSQL 16 date_add and date_subtract.

SqlData Integrity

Code

snippet
BEGIN;

-- Keep session in UTC so + INTERVAL uses 24-hour UTC days, while date_add uses the named zone
SET LOCAL TIME ZONE 'UTC';

WITH dst_edges AS (
    SELECT
        TIMESTAMPTZ '2026-03-08 06:30:00+00' AS spring_ny_0130, -- 01:30 EST before 02:00->03:00 jump
        TIMESTAMPTZ '2026-11-01 04:30:00+00' AS fall_ny_0030    -- 00:30 EDT before 02:00->01:00 repeat
)
SELECT
    spring_ny_0130 + INTERVAL '1 day' AS utc_plus_24h,
    date_add(spring_ny_0130, INTERVAL '1 day', 'America/New_York') AS ny_spring_23h,
    date_subtract(
        date_add(spring_ny_0130, INTERVAL '1 day', 'America/New_York'),
        INTERVAL '1 day',
        'America/New_York'
    ) AS roundtrip_spring,
    date_add(fall_ny_0030, INTERVAL '1 day', 'America/New_York') AS ny_fall_25h
FROM dst_edges;

COMMIT;

Walkthrough notes — DATE_ADD And DATE_SUBTRACT Across DST Shifts

At its core this is a single SELECT statement against dst_edges.

Mechanically, the statements are built from: a CTE (WITH … AS) that names an intermediate result before the main query.

Using it

Point it at the dst_edges table.

Key statements

SET LOCAL TIME ZONE 'UTC';

Interactive Tools for This Topic

FAQ

What objects does the SQL involve?
`dst_edges` — referenced directly, no join needed.