Dates & time
Scalar
time_bucket()
Truncate TIMESTAMPTZ by the specified interval bucket_width. Buckets are aligned relative to origin TIMESTAMPTZ. The origin defaults to 2000-01-03 00:00:00+00 for buckets that do not include a month or year interval, and to 2000-01-01 00:00:00+00 for month and year buckets
Reference: DuckDB 2.0.0
Arguments & returns
13 overloadstime_bucket(bucket_width, timestamp)
Scalar
time_bucket(bucket_width, timestamp, offset)
Scalar
time_bucket(bucket_width, timestamp, origin)
Scalar
time_bucket(bucket_width, timestamp, timezone)
Scalar
| Overload link | bucket_width | timestamp | timezone |
Returns |
|---|---|---|---|---|
| #13 | INTERVAL | TIMESTAMP WITH TIME ZONE | VARCHAR |
TIMESTAMP WITH TIME ZONE |
Example
Haybarn WASM 2.0.0-rc12 Β· In your browser
Engine example Β· Run to view results.
In other engines
PostgreSQL
SELECT DATE_BIN('30 days', timestamp_col, (SELECT MIN(TIMESTAMP) from table)) FROM table
SELECT TIME_BUCKET('30 days', timestamp_col, (SELECT MIN(TIMESTAMP) FROM "table")) FROM "table"
Snowflaketime_slice()
SELECT TIME_SLICE(DATE '2024-03-15', 1, 'DAY')
SELECT TIME_BUCKET(INTERVAL 1 DAY, CAST('2024-03-15' AS DATE))