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

Time:07-02

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,

CodePudding user response:

It's like this:

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