Skip to content

Instantly share code, notes, and snippets.

@gurjeet
Last active August 29, 2015 14:01
Show Gist options
  • Save gurjeet/088a91d6f45cfe1e842d to your computer and use it in GitHub Desktop.
Save gurjeet/088a91d6f45cfe1e842d to your computer and use it in GitHub Desktop.
Why timestamp(0) rounding is horrible
edb=# select now() as "time", now()::timestamptz(0) as "time_round", date_trunc('seconds', now()) as "time_trunc";
time | time_round | time_trunc
----------------------------------+---------------------------+---------------------------
21-MAY-14 14:19:04.549852 -04:00 | 21-MAY-14 14:19:05 -04:00 | 21-MAY-14 14:19:04 -04:00
(1 row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment