Re:Working with time in Postgres
by extesy on Thursday June 08, 2017 @06:53PM
(#14517794)
It's not the same: date_trunc returns timestamp, to_char returns a string.
[ Parent
| on HN ]
Re:Working with time in Postgres
by rainbowliquor on Thursday June 08, 2017 @07:00PM
(#14517846)
True but in the use case of OPs example. In the article OP says "So if we wanted to find the count of users that signed up per week:" which "2017-06-05 00:00:00+00" isn't a week, it's a date (with a time stamp as well which isn't pertinent) which happens to be the beginning of a week. Using TO_CHAR() with a format string makes it more legible and more recognizable.