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() ...

Get PostgreSQL Essential Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.