logoalt Hacker News

Handling dates and times in SQL queries with PostgreSQL

14 points • by metfan • last Thursday at 10:59 AM • 7 comments • view on HN

Comments

flossly • today at 11:36 AM

Lame article tbh.

It's better to use `timestampz` everywhere; the author seems to know but then uses `timestamp`...

Most of the functions showcased one will not need as one will do that in the app-layer or even in the frontend code.

ruslanty • last Thursday at 11:22 AM

For reports by local date, I’d convert both local midnights to timestamptz separately, then filter with ts >= start AND ts < end. If you take the first midnight and just add 24 hours, you can miss an hour or pull in an hour from the next day when the clocks change

traceroute66 • today at 11:33 AM

Interesting site, but its missing some of the more advanced things you can do in Postgres like `EXCLUDE USING gist` to prevent overlapping schedules.