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
Shared queries and folders ✅ Version history ✅ One-click connection to PostgreSQL ✅
Get more done, together, with PopSQL and PostgreSQL