PostgreSQL

How to Round Timestamps in PostgreSQL

Rounding/truncating timestamps are especially useful when you’re grouping by time. The function you need here is date_trunc:

select date_trunc('second', now()) -- or minute, hour, day, month