Open In App

PostgreSQL – CURRENT_DATE Function

Last Updated : 28 Aug, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The PostgreSQL CURRENT_DATE function returns the current date.

Syntax: CURRENT_DATE

Return value:

The CURRENT_DATE function returns a DATE value that represents the current date.

Example 1:

The following statement shows how to use the CURRENT_DATE function to get the current date:

SELECT CURRENT_DATE;

Output:

Example 2:

The CURRENT_DATE function can be used as a default value of a column. So create a table named delivery for demonstration:

CREATE TABLE delivery(
    delivery_id serial PRIMARY KEY,
    product varchar(255) NOT NULL,
    delivery_date DATE DEFAULT CURRENT_DATE
);

In the delivery table, there is the delivery_date whose default value is the result of the CURRENT_DATE function. Let’s add some data to it.

INSERT INTO delivery(product)
VALUES('Data Structure And Algorithm Edition 1');

Third, verify whether the row was inserted successfully with the current date by using the following:

SELECT * FROM delivery;

Output:


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads