PostgreSQL – How to Convert Timestamp to Date

You can convert a timestamp to a date in PostgreSQL using the DATE function. If you have a timestamp column named “order_ts” in a table called “orders,” you can use the following query to convert the timestamp to a date:

SELECT DATE(order_ts) FROM orders;

This will return a result set where each row contains the date portion of the corresponding timestamp value.

If you want to convert a specific timestamp value to a date, you can do it like this:

SELECT DATE('2023-08-31 14:30:00'::timestamp);

Replace '2023-08-31 14:30:00' with your desired timestamp value.

Using the DATE function like this will effectively remove the time portion of the timestamp and leave you with just the date.

Similar Posts