Posts about PostgreSQL

Handling dates and times in SQL queries with PostgreSQL

Getting the current date, extracting the month or week, formatting with to_char, adding an interval, computing an age or the difference between two dates: here is how to handle dates and times in SQL with PostgreSQL. With examples tested on PostgreSQL 18, the traps to avoid (now() frozen in the transaction, time zones, unused index) and a table of MySQL equivalents.