Time Data Types
PostgreSQL includes a number of built-in data types specifically designed to handle time- and date-related data.
A number of built-in constants are useful to know for simplifying date-time entry. The following is a list of them:
now—Constant that stores a timestamp upon storage.
today—Constant that refers to midnight on the current day.
tomorrow—Constant that refers to midnight on the next day.
yesterday—Constant that refers to midnight of the previous day.
PostgreSQL evaluates constants at the start of a transaction, and this might result in undesired behavior. For instance, using the now constant in a series inserted inside a transaction will result in all rows having the same timestamp. A way around this is to use the now() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access