PostgreSQL Date and Time Functions

This page lists the date and time functions that can be used to manipulate temporal values in PostgreSQL.

  1. age

    The PostgreSQL age() function calculate the age according to the specified birthday and returns the age in the format of x years x mons x days.
  2. clock_timestamp

    The PostgreSQL clock_timestamp() function returns the date and time when this function was executed. Two executions of clock_timestamp() may return different values.
  3. current_date

    The PostgreSQL current_date function returns the current system date in the format YYYY-MM-DD.
  4. current_time

    The PostgreSQL current_time function returns the system time with time zone information in the format HH:MM:SS.ssssss{+|-}ZZ.
  5. current_timestamp

    The PostgreSQL current_timestamp() function returns the current date and time (start of current transaction).
  6. date_bin

    The PostgreSQL date_bin() function truncates the specified timestamp to the beginning of the nearest specified interval.
  7. date_part

    The PostgreSQL date_part() function extracts the specified field from the specified timestamp or interval and returns the result.
  8. date_trunc

    The PostgreSQL date_trunc() function truncates a specified timestamp or interval value to the specified part and returns the result.
  9. extract

    The PostgreSQL extract() function extracts the specified field from the specified timestamp or time interval and returns it.
  10. isfinite

    The PostgreSQL isfinite() function detects whether a given date, timestamp or interval value is finite.
  11. justify_days

    The PostgreSQL justify_days() function converts the representation of time intervals, converting the number of days over 30 days to the number of months.
  12. justify_hours

    The PostgreSQL justify_hours() function converts the representation of time intervals, converting hours over 24 hours into days.
  13. justify_interval

    The PostgreSQL justify_interval() function converts the representation of time intervals, converting hours over 24 hours into days, and days over 30 days into months.
  14. localtime

    The PostgreSQL localtime function returns the current system time in the format HH:MM:SS.ssssss.
  15. localtimestamp

    The PostgreSQL localtimestamp() function returns the system date and time when the transaction started.
  16. make_date

    The PostgreSQL make_date() function creates a date from the given year, month, and day fields.
  17. make_interval

    The PostgreSQL make_interval() function creates an interval value from the given year, month, day, hour, minute, and second fields.
  18. make_time

    The PostgreSQL make_time() function creates a time from the given hour, minute, and second fields.
  19. make_timestamp

    The PostgreSQL make_timestamp() function creates a timestamp value from the given year, month, day, hour, minute, and second fields.
  20. make_timestamptz

    The PostgreSQL make_timestamptz() function creates a timestamp value from the given year, month, day, hour, minute, second, timezone fields.
  21. now

    The PostgreSQL now() function returns the system date and time when the current transaction started.
  22. pg_sleep

    The PostgreSQL pg_sleep() function suspends the execution of the current server process for the specified number of seconds.
  23. pg_sleep_for

    The PostgreSQL pg_sleep_for() function receives an interval parameter that pauses the execution of the current server process for the specified interval.
  24. pg_sleep_until

    The PostgreSQL pg_sleep_until() function receives a timestamp value and pauses the execution of the current server process until this specified moment.
  25. statement_timestamp

    The PostgreSQL statement_timestamp() function returns the timestamp for the starting execution of the current statement.
  26. timeofday

    The PostgreSQL timeofday() function returns a string representing the timestamp of when this function was executed.
  27. to_date

    The PostgreSQL to_date() function converts the specified string to a date value according to the given format.
  28. to_timestamp

    The PostgreSQL to_timestamp() function converts Unix epoch time to a standard timestamp with time zone information, or convert the specified string to timestamp according to the given format.
  29. transaction_timestamp

    The PostgreSQL transaction_timestamp() function returns the system date and time when the current transaction started.