问题
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