Back to cookbooks list Articles Cookbook

How to Get the Current Date in PostgreSQL

  • CURRENT_DATE

Problem:

You’d like to get the current date in a PostgreSQL database.

Solution:

We’ll use the function CURRENT_DATE to get the current date:

SELECT CURRENT_DATE;

Here’s the result of the query:

2019-10-24

Discussion:

The PostgreSQL CURRENT_DATE function returns the current date (the system date on the machine running PostgreSQL) as a value in the 'YYYY-MM-DD' format. In this format, YYYY is a 4-digit year, MM is a 2-digit month, and DD is a 2-digit day. The returned value is a date data type.

Discover the best interactive PostgreSQL courses

As you notice, this function has no brackets. Look at the next example:

SELECT CURRENT_DATE;

Here’s the result of the query:

2019-10-24

Recommended courses:

Recommended articles:

See also: