In PostgreSQL, the current_date
function returns the current date.
Syntax
The syntax goes like this:
current_date
So it doesn’t accept any parameters.
Note that no parentheses are required (or accepted).
Example
Here’s a basic example to demonstrate.
SELECT current_date;
Result:
2020-07-01
The actual date is based on the start date/time of the current transaction. Therefore, it doesn’t change as the transaction progresses.
So for example, if you start a transaction just before midnight, and the transaction continues through to the next day, the date returned by current_date()
will be the date the transaction was started, regardless of whether current_date()
is called prior to midnight or after.
This allows a single transaction to have a consistent notion of the “current” time, so that multiple modifications within the same transaction bear the same time stamp.