BigQuery · Date function
BigQuery DATE_BUCKET
DATE_BUCKET(date, INTERVAL n DAY) returns the first day of the fixed-width bucket that contains a date, counted from an origin (1950-01-01 by default). Use it for 7-day, 14-day or N-month periods that DATE_TRUNC can't express.
DATE_BUCKET is a time series function, generally available in BigQuery since August 2024. It splits the calendar into equal buckets that start at an origin date and extend in both directions, and returns the lower bound of the bucket each date falls in. DATE_TRUNC only knows calendar units; DATE_BUCKET handles two-week sprints, 28-day cycles or 4-month terms.
The width must be a single-part INTERVAL built from date parts: INTERVAL 14 DAY, INTERVAL 2 WEEK or INTERVAL 3 MONTH. Time parts such as HOUR fail with "Only MONTH and DAY parts are allowed in bucket width INTERVAL", and zero or negative widths are rejected. For buckets of hours or minutes, use DATETIME_BUCKET or TIMESTAMP_BUCKET.
The default origin, 1950-01-01, was a Sunday, so INTERVAL 7 DAY buckets start on Sundays. Pass any Monday, such as DATE '2026-01-05', as the third argument for Monday weeks or to align sprints with a real start date.
Syntax
DATE_BUCKET(date_in_bucket, bucket_width)
DATE_BUCKET(date_in_bucket, bucket_width, bucket_origin_date)Arguments and return value
| Argument | Description |
|---|---|
date_in_bucket | The DATE to place in a bucket. NULL returns NULL. |
bucket_width | A single-part INTERVAL with a date part: DAY, WEEK, MONTH, QUARTER or YEAR, for example INTERVAL 14 DAY. Must be positive. |
bucket_origin_date | Optional DATE that one bucket starts on. Defaults to 1950-01-01. |
Returns: DATE: the first day of the bucket that contains date_in_bucket.
Examples
7-day buckets: default origin versus a Monday origin
2026-11-25 is a Wednesday. The default origin is a Sunday, so the bucket starts on Sunday, November 22.
SELECT
DATE_BUCKET(DATE '2026-11-25', INTERVAL 7 DAY) AS default_origin,
DATE_BUCKET(DATE '2026-11-25', INTERVAL 7 DAY, DATE '2026-01-05') AS monday_origin;| default_origin | monday_origin |
|---|---|
| 2026-11-22 | 2026-11-23 |
Two-week sprints
Sprints start every 14 days from Monday, January 5, 2026.
WITH tickets AS (
SELECT 'T-1' AS ticket_id, DATE '2026-11-20' AS closed_on UNION ALL
SELECT 'T-2', DATE '2026-11-23' UNION ALL
SELECT 'T-3', DATE '2026-11-30' UNION ALL
SELECT 'T-4', DATE '2026-12-07'
)
SELECT
DATE_BUCKET(closed_on, INTERVAL 14 DAY, DATE '2026-01-05') AS sprint_start,
COUNT(*) AS closed_tickets
FROM tickets
GROUP BY sprint_start
ORDER BY sprint_start;| sprint_start | closed_tickets |
|---|---|
| 2026-11-09 | 1 |
| 2026-11-23 | 2 |
| 2026-12-07 | 1 |
Month buckets and a custom billing day
With an origin on the 15th, each one-month bucket runs from the 15th to the 14th of the next month.
SELECT
DATE_BUCKET(DATE '2026-11-23', INTERVAL 1 MONTH) AS month_bucket,
DATE_BUCKET(DATE '2026-11-23', INTERVAL 3 MONTH) AS quarter_bucket,
DATE_BUCKET(DATE '2026-11-23', INTERVAL 1 MONTH, DATE '2026-01-15') AS billing_cycle;| month_bucket | quarter_bucket | billing_cycle |
|---|---|---|
| 2026-11-01 | 2026-10-01 | 2026-11-15 |
Common mistakes
- Assuming 7-day buckets start on Monday. The default origin 1950-01-01 is a Sunday; pass a Monday origin, or use
DATE_TRUNC(d, WEEK(MONDAY))for plain weeks. - Using time parts.
INTERVAL 12 HOURfails on a DATE; convert to DATETIME and use DATETIME_BUCKET. - Passing a multi-part interval such as
INTERVAL '1 2' MONTH TO DAY, or a negative or zero width. All of these are errors. - Porting Snowflake's
TIME_SLICE(d, 14, 'DAY')or PostgreSQL'sdate_bin. DATE_BUCKET is the BigQuery equivalent for dates, but check the origin: the results only match if both use the same starting point.
Cost and performance
- DATE_BUCKET is not on BigQuery's list of functions that keep partition pruning when they wrap a partitioning column. Filter the partition column with a plain date range, and use DATE_BUCKET only in SELECT and GROUP BY.
FAQ
Is DATE_BUCKET available in BigQuery?
Yes. DATE_BUCKET, DATETIME_BUCKET and TIMESTAMP_BUCKET are documented with the time series functions, which became generally available in August 2024.
What is the difference between DATE_BUCKET and DATE_TRUNC?
DATE_TRUNC snaps to calendar units such as WEEK or MONTH. DATE_BUCKET uses any width, such as 14 days or 4 months, measured from an origin you choose.
How do I group dates into 2-week periods?
DATE_BUCKET(d, INTERVAL 14 DAY, DATE '2026-01-05'), where the origin is the first day of any period you want to align with.
Related
More date functions
All BigQuery date functions · All functions · BigQuery error messages
