select to_date(to_char(sysdate,'yyyy-mm-dd hh12:mi:ss AM'), 'yyyy-MM-dd HH12:MI:SS AM') from dual;
This works fine in oracle but not in Postgres.
Instead of sysdate
you should use current_timestamp
, or now()
:
SELECT TO_CHAR(current_timestamp, 'yyyy-mm-dd hh12:mi:ss AM')
A table for add AM or PM format itself.
create table date_tbl ( id serial, Date_time varchar (30) default TO_CHAR(current_timestamp, 'yyyy-mm-dd hh:mi:ss AM') )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With