PostgreSQL Date Functions

The following page shows the most commonly used PostgreSQL date functions that allow you to manipulate date and time values effectively.

FunctionReturn TypeDescription
AGEINTERVALCalculate ages between two timestamps and returns a “symbolic” result which uses years and months
AGEINTERVALCalculate ages between current date (at midnight) and a timestamp and returns a “symbolic” result which uses years and months
CLOCK_TIMESTAMPTIMESTAMPTZReturn the current date and time which changes during statement execution
CURRENT_DATEDATEReturn the current date
CURRENT_TIMETIMESTAMPTZReturn the current time
CURRENT_TIMESTAMPTIMESTAMPTZReturn the current date and time with time zone at which the current transaction starts
DATE_PARTDOUBLE PRECISIONGet a field of a timestamp or an interval e.g., year, month, day, etc.
DATE_TRUNCTIMESTAMPReturn a timestamp truncated to a specified precision
EXTRACTDOUBLE PRECISIONSame as DATE_PART() function
ISFINITEBOOLEANCheck if a date, a timestamp, or an interval is finite or not (not +/-infinity)
JUSTIFY_DAYSINTERVALAdjust interval so 30-day time periods are represented as months
JUSTIFY_HOURSINTERVALAdjust interval so 24-hour time periods are represented as days
JUSTIFY_INTERVALINTERVALAdjust interval using justify_days and justify_hours, with additional sign adjustments
LOCALTIMETIMEReturn the time at which the current transaction start
LOCALTIMESTAMPTIMESTAMPReturn the date and time at which the current transaction start
NOWTIMESTAMPTZReturn the date and time with time zone at which the current transaction start
STATEMENT_TIMESTAMPTIMESTAMPTZReturn the current date and time at which the current statement executes
TIMEOFDAYTEXTReturn the current date and time, like clock_timestamp, as a text string)
TRANSACTION_TIMESTAMPTIMESTAMPTZSame as NOW() function
TO_DATEDATEConvert a string to a date
TO_TIMESTAMPTIMESTAMPTZConvert a string to a timestamp