Time Functions
The following functions assist in performing calculations based on time- and date-related material. These are useful in performing calculations and transformations of temporal-related data sets.
AGE
Description
The AGE function returns an interval that represents the difference between the current time and the time argument supplied.
Inputs
AGE(timestamp)—Computes the difference between the timestamp supplied and now().
AGE(timestamp, timestamp)—Computes the difference between the two supplied timestamps.
Example
AGE('03-01-2001 15:56:00', '11-01-2001 14:22:00') → 7 mon 30 22:26 ago
CURRENT_DATE
Description
The CURRENT_DATE function returns the current system date.
Inputs
None.
Example
SELECT CURRENT_DATE; → 2001-06-11 ...
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.