Skip to content

CURRENT_TIMESTAMP

Return the date and time when the current transaction starts. This value does not change during the course of a transaction and does not reflect the individual start times of statements within a transaction.

CURRENT_TIMESTAMP[(6)]

The number 6 (for the fractional seconds part of the timestamp) is optional and does not affect the result. This function always returns a precision of 6. You may see results with fewer than 6 fractional seconds because trailing zeroes are not returned. The return type is TIMESTAMPTZ.

For example:

premdb=# select current_timestamp;
             now              
-------------------------------
 2018-03-25 22:47:36.725768-07
(1 row)

premdb=# select current_timestamp(6);
         timestamptz          
-------------------------------
 2018-03-25 22:47:38.891822-07
(1 row)

premdb=# select current_timestamp from sys.const;
            now              
------------------------------
 2018-03-25 22:49:45.06732-07
(1 row)

You can extract supported date parts from the CURRENT_TIMESTAMP result:

premdb=# SELECT EXTRACT(week FROM CURRENT_TIMESTAMP);
 date_part 
-----------
       20
(1 row)

premdb=# SELECT EXTRACT(w FROM CURRENT_TIMESTAMP);
 date_part 
-----------
       20
(1 row)

You can use the result of this function to calculate intervals between the current timestamp and other datetime values in the database.

Note: The CURRENT_TIME function is not supported. Use LOCALTIME.