The DateBucket function released in the new SQL Server 2022.

Опубликовано: 10 Май 2025
на канале: SQL Data Ninja
653
11

The DATE_BUCKET function is a SQL function that groups a set of date/time values into a specified time interval or "bucket."
The function takes three arguments: the datepart, the interval by which to group the data (e.g. "1 day," "1 week," "1 month," etc.) and the date/time column to be grouped. The optional fourth argument is the “origin” which is a beginning date.