How to Round Timestamps

select 	'2021-03-20,09:34:45.123'::timestamp                    original_value,
    date_trunc('hour', '2021-03-20 09:34:45.123'::timestamp)    rounded_to_hour,
    date_trunc('minute', '2021-03-20 09:34:45.123'::timestamp)  rounded_to_minute,
    date_trunc('day', '2021-03-20 09:34:45.123'::timestamp)     rounded_to_day,
    date_trunc('month', '2021-03-20 09:34:45.123'::timestamp)   rounded_to_month
original_value rounded_to_hour rounded_to_minute Rounded_to_day rounded_to_month
2021-03-20 09:34:45.123 2021-03-20 09:00:00 2021-03-20 09:34:00 2021-03-20 00:00:00 2021-03-01,00:00:00

IN THIS PAGE