How to Extract Date From Timestamp in PostgreSQL
Joy Idialu
Feb 02, 2024
PostgreSQL
PostgreSQL Date
-
Use the
CAST
Operator to Extract Date From Timestamp in PostgreSQL -
Use the
DATE
Function to Extract Date From Timestamp in PostgreSQL

PostgreSQL provides many functions and operators for the built-in data types. This tutorial will give examples of extracting the date from the timestamp in PostgreSQL or Postgres.
Use the CAST
Operator to Extract Date From Timestamp in PostgreSQL
In PostgreSQL, the CAST
function converts one datatype value to another. We can use it to extract the date from the timestamp.
select CAST ('2021-11-03 13:10:00' as date);
Output:
date
------------
2021-11-03
Another way to cast is to use the scope resolution ::
operator accompanied with the resulting type in this case date.
select '2021-11-03 13:10:00'::date;
Output:
date
------------
2021-11-03
Use the DATE
Function to Extract Date From Timestamp in PostgreSQL
You can implement the DATE
function to extract the date only from a timestamp.
select date ('2021-11-03 13:10:00');
Output:
date
------------
2021-11-03
Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe