I have a dates that I need to aggregate into quarter/year format in SQL Presto. Please help. Thanks!
I have a dates that I need to aggregate into quarter/year format in SQL Presto. Please help. Thanks!
Documentation is your friend - use either date_trunc with corresponding unit, or extraction functions (year, quarter):
select date_trunc('quarter', now())
, date_trunc('year', now())
, quarter(now())
, year(now())
Sample output:
| _col0 | _col1 | _col2 | _col3 |
|---|---|---|---|
| 2022-07-01 00:00:00.000 UTC | 2022-01-01 00:00:00.000 UTC | 3 | 2022 |