PostgreSQL Tutorial

  • Home
  • Stored Procedures
  • Triggers
  • Views
  • Interfaces
    • PostgreSQL PHP
    • PostgreSQL Python
    • PostgreSQL JDBC
  • Functions
    • Aggregate Functions
    • Date / Time Functions
    • String Functions
    • Math Functions
Home / PostgreSQL Date Functions

PostgreSQL Date Functions

The following page shows you the most commonly used PostgreSQL date functions that allow you to manipulate date and time values more 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
Previous Tutorial: PostgreSQL Aggregate Functions
Next Tutorial: PostgreSQL String Functions

PostgreSQL Date Functions

  • AGE
  • CURRENT_DATE
  • CURRENT_TIME
  • CURRENT_TIMESTAMP
  • EXTRACT
  • LOCALTIME
  • LOCALTIMESTAMP
  • DATE_PART
  • DATE_TRUNC
  • NOW
  • TO_DATE
  • TO_TIMESTAMP

About PostgreSQL Tutorial

PostgreSQLTutorial.com is a website dedicated to developers and database administrators who are working on PostgreSQL database management system.

We constantly publish useful PostgreSQL tutorials to keep you up-to-date with the latest PostgreSQL features and technologies. All PostgreSQL tutorials are simple, easy-to-follow and practical.

Recent PostgreSQL Tutorials

  • PostgreSQL ANY Operator
  • PostgreSQL EXISTS
  • How To Delete Duplicate Rows in PostgreSQL
  • PostgreSQL TO_CHAR Function
  • PostgreSQL TO_NUMBER Function
  • PostgreSQL TO_TIMESTAMP Function
  • PostgreSQL CEIL Function
  • PostgreSQL MOD Function
  • PostgreSQL FLOOR Function
  • PostgreSQL ABS Function

More Tutorials

  • PostgreSQL Cheat Sheet
  • PostgreSQL Administration
  • PostgreSQL PHP
  • PostgreSQL Python
  • PostgreSQL JDBC
  • PostgreSQL Resources

Site Info

  • Home
  • About Us
  • Contact Us
  • Privacy Policy

Copyright © 2017 by PostgreSQL Tutorial Website. All Rights Reserved.