How do you convert a string to a timestamp?
The documentation and all answers that I have found show how to convert at string column to timestamp with the to_timestamp function, but this apparently does not work for a single string.
to_timestamp('2019-09-20 13:59', 'DD-MM-YYYY HH24:MI:SS')
Cast('2019-09-20 13:59' as timestamp)
I want to add a column to a table with this date as a repeated value.
-- Creating timestamp column
ALTER TABLE my_table ADD creation_date timestamp
-- Repeating timestamp
UPDATE my_table SET creation_date = TO_TIMESTAMP('2019-09-20 13:59', 'YYYY-MM-DD HH24:MI')
You can try below - change your format mask from 'DD-MM-YYYY HH24:MI:SS'
to 'YYYY-MM-DD HH24:MI:SS'
DEMO
select to_timestamp('2019-09-20 13:59', 'YYYY-MM-DD HH24:MI:SS')
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