Postgresql – How to get current day, month, year from date

Run the below command to get current day, month and year from date in postgres database.

Sql query to view today’s date:

select CURRENT_DATE;

Sql to get day of the week from today’s date:

select EXTRACT(DAY FROM CURRENT_DATE) AS day;

Sql query to get current month from date:

select EXTRACT(MONTH FROM CURRENT_DATE) AS month;

Sql query to get current year using date:

select EXTRACT(YEAR FROM CURRENT_DATE) AS year;
See also  PostgreSQL - Get database size