---
title: "time_bucket function in Strata | Oplema"
description: "Truncate timestamps to the start of a bucket of a width you choose, such as every 15 minutes. Use it in a Strata Formula or Filter."
url: "https://oplema.com/docs/strata/functions/time-bucket"
updated: "2026-11-04"
---

# time\_bucket

Round a date or timestamp down to the start of a fixed-width bucket, such as every 2 days. Buckets count from 2000-01-03, or from 2000-01-01 for month and year buckets, unless you pass your own origin.

## Try an expression

In [Formula](https://oplema.com/docs/strata/prep/formula), enter the expression and set Output type to **DATE**.

### Expression

```
time_bucket(INTERVAL '2 days', DATE '2024-01-04')
```

### Result

```
2024-01-03
```

To use your own data, replace the example values with column names. Keep format strings and other options as written.

Try it live in Formula

Result
| id | result |
| --- | --- |
| 1 | 2024-01-03 |

## Arguments and types

```
time_bucket(bucket_width, timestamp, origin)
```

**bucket\_width**

Interval

**timestamp**

Date, Timestamp

**origin**

Date, Interval, Timestamp, Text

Supported signatures (10)

```
time_bucket(bucket_width: INTERVAL, timestamp: DATE) → DATE
time_bucket(bucket_width: INTERVAL, timestamp: DATE, origin: DATE) → DATE
time_bucket(bucket_width: INTERVAL, timestamp: DATE, origin: INTERVAL) → DATE
time_bucket(bucket_width: INTERVAL, timestamp: TIMESTAMP WITH TIME ZONE) → TIMESTAMP WITH TIME ZONE
time_bucket(bucket_width: INTERVAL, timestamp: TIMESTAMP WITH TIME ZONE, origin: INTERVAL) → TIMESTAMP WITH TIME ZONE
time_bucket(bucket_width: INTERVAL, timestamp: TIMESTAMP WITH TIME ZONE, origin: TIMESTAMP WITH TIME ZONE) → TIMESTAMP WITH TIME ZONE
time_bucket(bucket_width: INTERVAL, timestamp: TIMESTAMP WITH TIME ZONE, origin: VARCHAR) → TIMESTAMP WITH TIME ZONE
time_bucket(bucket_width: INTERVAL, timestamp: TIMESTAMP) → TIMESTAMP
time_bucket(bucket_width: INTERVAL, timestamp: TIMESTAMP, origin: INTERVAL) → TIMESTAMP
time_bucket(bucket_width: INTERVAL, timestamp: TIMESTAMP, origin: TIMESTAMP) → TIMESTAMP
```

The result type can depend on the input types. See DuckDB for the full argument rules.

## Things to know

If the first argument is missing, the result is NULL.

## Related functions

[date\_trunc

Round a date or timestamp down to the start of a unit such as month or year. Also available as datetrunc.

](https://oplema.com/docs/strata/functions/date-trunc)[to\_months

Turn a number into an interval of that many months.

](https://oplema.com/docs/strata/functions/to-months)[to\_years

Turn a number into an interval of that many years.

](https://oplema.com/docs/strata/functions/to-years)[date\_add

Move a date or timestamp forward or backward by an interval.

](https://oplema.com/docs/strata/functions/date-add)

[Browse dates & times](https://oplema.com/docs/strata/functions#dates-&-times) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/timestamptz.html#time_bucketbucket_width-timestamptz-timezone)

Function metadata from DuckDB, used under the [MIT license](https://github.com/duckdb/duckdb/blob/v1.5.4/LICENSE).
