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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.