Handling dates and times in SQL queries with PostgreSQL
Comments
Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules
Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules
Summary
This article is a PostgreSQL guide to handling dates and times in SQL, written as a counterpart to an earlier MySQL and MariaDB piece by the same site. It covers getting the current time (now() versus clock_timestamp()), extracting and truncating date parts with EXTRACT and date_trunc, formatting with to_char, adding…