Extracting dates from timestamp in postgresql

Asked 2 years ago, Updated 2 years ago, 46 views

I am using postgresql. There is a timestamp type column and an id column.

I want to extract it like this.

select date, count(distinct(id)) from table group by date

How do I get the date when I want to use query like?

postgresql

2022-09-21 17:40

1 Answers

It's a self-answer.

column_name::timestamp::date

That's how it works. Instead of columnn_name, you can put the column name in the timestamp format.


2022-09-21 17:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.