current_date

A function returning the date the current transaction started

current_date is a system function returning the date at which the current transaction started.

current_date was added in PostgreSQL 6.2.

Usage

current_date → date

Despite its name, current_date returns the date when the current transaction was started, not the actual date the function was executed (this can be retrieved via clock_timestamp()).

Note that current_date cannot be invoked as current_date().

Change history

Examples

Basic execution example for current_date:

postgres=# SELECT current_date;
 current_date 
--------------
 2021-06-17
(1 row)

current_date will always report the same date as transaction_timestamp(), and (if executed in an implicit transaction) the same date as statement_timestamp():

postgres=# SELECT
              current_date,
              transaction_timestamp(),
              statement_timestamp(),
              clock_timestamp()\gx
-[ RECORD 1 ]---------+------------------------------
current_date          | 2021-06-19
transaction_timestamp | 2021-06-19 08:48:18.386946+09
statement_timestamp   | 2021-06-19 08:48:18.386946+09
clock_timestamp       | 2021-06-19 08:48:18.387096+09

In practice the date returned by all of these functions will usually be the same, but may of course differ for transactions started close to the end od the day.

The variant current_date() is not valid:

postgres=# SELECT current_date();
ERROR:  syntax error at or near "("
LINE 1: SELECT current_date();
                           ^

Categories

Date and time, System function

See also

current_timestamp, current_time, transaction_timestamp(), clock_timestamp()