How to Use DATEDIFF in Snowflake
Last updated July 25, 2026 · By the SaturnSQL team
DATEDIFF(part, start, end) returns the difference between two dates or timestamps in the given unit, e.g. DATEDIFF(day, created_at, shipped_at). It counts unit boundaries crossed, not elapsed time, so two timestamps a minute apart can differ by 1 day.
SELECT
id,
DATEDIFF(day, created_at, shipped_at) AS days_to_ship,
DATEDIFF(hour, created_at, shipped_at) AS hours_to_ship
FROM orders;Common date parts
Accepted parts include year, quarter, month, week, day, hour, minute, and second. The result is negative when the end is before the start.
SELECT DATEDIFF(month, '2026-01-15', '2026-07-01'); -- 6Gotcha: boundaries, not duration
DATEDIFF counts how many boundaries of the unit are crossed. For true elapsed time, diff in a smaller unit and divide.
SELECT DATEDIFF(year, '2025-12-31', '2026-01-01'); -- 1, despite being one day apartRun 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