Stephen Yorke
Stephen Yorke

Reputation: 307

Example of how to convert postgres text time with am/pm to a timestamp

I have a date time field in postgres like 06/29/2022 1:24 pm and I'd like to cast it to 2022-06-29 13:32:00

I know it's something close to this

select to_timestamp(created, 'YYYY-MM-DD HH24:MI:SS p')

but I cannot find an example for the am/pm part.

Thanks,

Upvotes: 0

Views: 938

Answers (1)

Pepe N O
Pepe N O

Reputation: 2344

It's like this:

select to_timestamp('06/29/2022 1:24 pm', 'mm/dd/yyyy hh12:mi am,pm');

Upvotes: 2

Related Questions