I need to change a column of timestamps (date_col) to be formatted as yyyy-01-01. January first of the year in the date_col
Example:
actual desired
2021-04-02 00:00:00.000 2021-01-01
1966-05-04 00:00:00.000 1966-01-01
>Solution :
Please use date_trunc
select date_trunc(year,'2021-04-02 00:00:00.000'::date);
+--------------------------------------------------+
| DATE_TRUNC(YEAR,'2021-04-02 00:00:00.000'::DATE) |
|--------------------------------------------------|
| 2021-01-01 |
+--------------------------------------------------+