DATE_BUCKET
date/time arithmetic, parts, construction or truncation
What changes
- Input
- date/time arguments
- Output or change
- date/time or integer value
- Return type
- The return value data type for this method is dynamic. The return type depends on the argument supplied for date. If a valid input data type is supplied for date, DATE_BUCKET returns the same data typ
Syntax at a glance
DATE_BUCKET (datepart , number , date [ , origin ] )
Work example
Place timestamps into fixed-width time buckets for grouped analysis.
Set the interval width and origin deliberately, then test values on both sides of a bucket edge.
Check your work DATE_BUCKET returns a bucket start and its origin changes bucket alignment.
Practice SQL
Open in SQL FlowSELECT DATE_BUCKET(hour, 6, CONVERT(datetime2, '2026-04-05T13:20:00')) AS bucket_start;
Open Microsoft Learn for full syntax, permissions, and details for your version.