eduardosufan
eduardosufan

Reputation: 1582

select only HH:MM:SS (hour, minutes and seconds) from timestamp column in postgres

I have a postgresql database with a column with timestamptz data (YYYY-MM-DD HH:MM:SS) and I want to do a query only of the HH:MM:SS.

In the example, "ingested" column name is the one with the timesamptz

select ingested from my_database

This is an data example: 2020-12-23 12:18:13 How can I get 12:18:13 only?

Upvotes: 0

Views: 2762

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269693

You can convert to time:

select ingested::time

To avoid the milliseconds:

select ingested::time(0)

Upvotes: 2

Related Questions