将字符串转换为日期,没有破折号

Converting string to date, with no dashes

我有一个 timestamp 字段,它是一个字符串,我需要将它转换为日期或日期时间。我的时间戳值显示如下:

20201123T21:11:00

几天来我一直在谷歌搜索解决方案,但没有成功。我最接近的答案是将 2020-11-23T21:11:00 之类的内容转换为日期值,但显然这行不通,因为我的时间戳值不包含破折号。

提前感谢您的帮助!

使用:

select date_parse('20201123T21:11:00','%Y%m%dT%H:%i:%s')

例如:

select date_parse(timestamp_field,'%Y%m%dT%H:%i:%s') from table

参考:Date and Time Functions and Operators — Presto Documentation