An open API service indexing awesome lists of open source software.

https://github.com/stefanov-sm/pre-pg14-date_bin-function

Postgresql date_bin for versions prior to 14. Can be used for running interval aggregation in time series data scenarios.
https://github.com/stefanov-sm/pre-pg14-date_bin-function

postgresql sql

Last synced: about 1 month ago
JSON representation

Postgresql date_bin for versions prior to 14. Can be used for running interval aggregation in time series data scenarios.

Awesome Lists containing this project

README

        

## Postgresql date_bin function for versions prior to PG14
#### Postgresql `date_trunc` by interval. Can be used for running interval aggregation in time series data scenarios.
```sql
function date_bin(trunc_period interval, ts timestamptz, base_ts timestamptz default 'epoch')
returns timestamptz;
```
#### Demo
```sql
select now(), date_bin(interval '10 seconds', now());
```
yields
2021-09-13 23:18:**27.256826**, 2021-09-13 23:18:**20.0**