How to Use DATEDIFF in Redshift
Last updated July 25, 2026 · By the SaturnSQL team
DATEDIFF(part, start, end) returns the whole number of date-part boundaries crossed between two dates, and DATEADD(part, n, date) shifts a date. Parts include day, week, month, quarter, year, hour, minute, second.
SELECT DATEDIFF(day, '2026-07-01', '2026-07-25') AS days,
DATEDIFF(month, '2026-01-15', '2026-07-01') AS months,
DATEADD(hour, -6, GETDATE()) AS six_hours_ago;Age of each order in days
SELECT id, DATEDIFF(day, created_at, GETDATE()) AS age_days
FROM orders
ORDER BY age_days DESC;DATEDIFF counts boundary crossings, not elapsed time: DATEDIFF(year, '2025-12-31', '2026-01-01') is 1 even though only one day passed.
Run this in SaturnSQL
SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.
Try it free