I have a timestamp string value from source data which I wanted to convert into required format. Any idea on converting the string into timestamp is much appreciated.
String value of source data
'Fri Oct 16 03:27:06 PDT 2020'
I want above string to be converted into
YYYY-MM-DD HH24:MI:SS
which should be like from the sample string shared
2020-10-16 03:27:06
As of now trying with below, but this sounds like not a good practice to have.
select to_timestamp(substr('Fri Oct 16 03:27:06 PDT 2020',5,15)||' '||substr('Fri Oct 16 03:27:06 PDT 2020',25),'MON DD HH24:MI:SS YYYY');
Any help to achieve the desired output would be great. Thanks!
After converting it to timezone, you can show it in any format:
select to_varchar( to_timestamp( 'Fri Oct 16 03:27:06 PDT 2020', 'DY MON DD HH24:MI:SS TZD YYYY') , 'YYYY-MM-DD HH24:MI:SS') ;
Clean version:
SELECT to_varchar( column1, 'YYYY-MM-DD HH24:MI:SS')
FROM VALUES (to_timestamp( 'Fri Oct 16 03:27:06 PDT 2020', 'DY MON DD HH24:MI:SS TZD YYYY'));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.