【问题标题】:Convert DateString with offset to a valid Date/Timestamp in Athena / Presto将带有偏移量的 DateString 转换为 Athena / Presto 中的有效日期/时间戳
【发布时间】:2019-09-19 01:29:51
【问题描述】:

我正在尝试将日期字符串字段转换为日期。问题是字符串字段中有东部时间的偏移量。如何将其转换为日期时间?

日期字符串:2016-09-21T10:01:43-04:00

这必须在 Amazon AWS Athena 中转换为有效的日期时间。 试过 From_iso8601_timestamp,date_parse。但没有运气。

【问题讨论】:

标签: sql datetime amazon-athena presto timezone-offset


【解决方案1】:

使用from_iso8601_timestamp:

presto> select from_iso8601_timestamp('2016-09-21T10:01:43-04:00');
             _col0
--------------------------------
 2016-09-21 10:01:43.000 -04:00

(在 Presto 309 上测试,但也应该在 Athena 中工作)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-16
    • 2018-12-19
    • 2018-02-20
    • 2016-10-23
    • 1970-01-01
    • 2021-06-12
    • 2021-06-18
    • 2018-04-03
    相关资源
    最近更新 更多