How do I convert a string which is actually a date with timezone to a timestamp in Presto?

烂漫一生 提交于 2019-12-24 20:00:56

问题


Example : 2017-12-24 23:59:59.000 PST

This does not work

select date_parse('2017-12-24 23:59:59.000 PST','%Y-%m-%d %T.%f %x')

Sure I can truncate the TZ which will solve

select date_parse(substr('2017-12-24 23:59:59.000 PST',1,23),'%Y-%m-%d %T.%f')

Is there a way to do this without truncating the TZ ?


回答1:


date_parse doesn't seem to support time zones, use parse_datetime instead:

presto> select parse_datetime('2017-12-24 23:59:59.000 PST', 'YYYY-MM-dd HH:mm:ss.SSS z');
                    _col0
---------------------------------------------
 2017-12-24 23:59:59.000 America/Los_Angeles
(1 row)


来源:https://stackoverflow.com/questions/48070592/how-do-i-convert-a-string-which-is-actually-a-date-with-timezone-to-a-timestamp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!