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
database icon
Finally, a unified workspace for your SQL development
Get more done, together, with PopSQL and PostgreSQL