DATEDIFF
date/time arithmetic, parts, construction or truncation
What changes
- Input
- date/time arguments
- Output or change
- date/time or integer value
- Return type
- int
Syntax at a glance
DATEDIFF ( datepart , startdate , enddate )
Work example
Count datepart boundaries crossed between two timestamps.
Choose the smallest datepart that matches the question and test values around a boundary.
Check your work DATEDIFF counts boundaries crossed, not elapsed whole units.
Practice SQL
Open in SQL FlowSELECT DATEDIFF(day, CONVERT(date, '2026-04-05'), CONVERT(date, '2026-04-06')) AS day_boundaries;
Open Microsoft Learn for full syntax, permissions, and details for your version.