Skip to content

Commit 1367f2a

Browse files
docs: explain date_bin daylight saving behavior
1 parent c3ef346 commit 1367f2a

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

‎datafusion/functions/src/datetime/date_bin.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ use chrono::{DateTime, Datelike, Duration, Months, TimeDelta, Utc};
5353
Calculates time intervals and returns the start of the interval nearest to the specified timestamp. Use `date_bin` to downsample time series data by grouping rows into time-based "bins" or "windows" and applying an aggregate or selector function to each window.
5454
5555
For example, if you "bin" or "window" data into 15 minute intervals, an input timestamp of `2023-01-01T18:18:18Z` will be updated to the start time of the 15 minute bin it is in: `2023-01-01T18:15:00Z`.
56+
57+
Bins are anchored to an origin instant (the UNIX epoch by default); an origin does not adjust for daylight saving time. For example, a bin aligned to midnight in `America/Denver` can shift to 01:00 after the spring daylight saving transition. Use `date_trunc` for calendar units such as local days. To bin other intervals on local wall-clock boundaries, convert the timestamp with `to_local_time(expression AT TIME ZONE '<zone>')` before calling `date_bin`, then apply `AT TIME ZONE` to the result if a timezone-aware timestamp is needed.
5658
"#,
5759
syntax_example = "date_bin(interval, expression[, origin_timestamp])",
5860
sql_example = r#"```sql

‎docs/source/user-guide/sql/scalar_functions.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,6 +2472,8 @@ Calculates time intervals and returns the start of the interval nearest to the s
24722472

24732473
For example, if you "bin" or "window" data into 15 minute intervals, an input timestamp of `2023-01-01T18:18:18Z` will be updated to the start time of the 15 minute bin it is in: `2023-01-01T18:15:00Z`.
24742474

2475+
Bins are anchored to an origin instant (the UNIX epoch by default); an origin does not adjust for daylight saving time. For example, a bin aligned to midnight in `America/Denver` can shift to 01:00 after the spring daylight saving transition. Use `date_trunc` for calendar units such as local days. To bin other intervals on local wall-clock boundaries, convert the timestamp with `to_local_time(expression AT TIME ZONE '<zone>')` before calling `date_bin`, then apply `AT TIME ZONE` to the result if a timezone-aware timestamp is needed.
2476+
24752477
```sql
24762478
date_bin(interval, expression[, origin_timestamp])
24772479
```

0 commit comments

Comments
 (0)