DATE_BUCKET() - simplify analytics on datetime values
Data Warehouse · General availability · Shipped
Description
The `DATE_BUCKET()` function groups dates into buckets of arbitrary length and returns the starting date of each bucket. This function is particularly useful for performing analytics on datetime columns when you need to aggregate or group values by time intervals.The following example shows how to group the values into 2-week buckets and count the number of records in each bucket:<br/>
```SELECT date_period = DATE_BUCKET(WEEK, 2, updated), count = COUNT(*) FROM dbo.bing_covid19_data GROUP BY DATE_BUCKET(WEEK, 2, updated)```
Change History
-
2025-12-18
Release Status Planned -> Shipped -
2025-10-31
Roadmap Item Added
Workload: Data Warehouse