【问题标题】:Error while converting timestamp string with timezone (+0000) to Timestamp in Presto在 Presto 中将带时区 (+0000) 的时间戳字符串转换为时间戳时出错
【发布时间】:2021-08-29 17:28:12
【问题描述】:

我正在尝试使用 date_parse 将时间戳字符串转换为时间戳,但不断出现错误。有什么建议?我正在研究 Presto SQL。我还提到了:http://teradata.github.io/presto/docs/127t/functions/datetime.html,但找不到任何可以处理 +0000 即时区的东西。

我试过了:

date_parse('2021-05-22 04:00:00 +0000', '%Y-%m-%d %h:%i:%s')

抛出错误格式无效:“2021-05-22 04:00:00 +0000”在“+0000”处格式错误

也试过这个:

date_parse('2021-05-22 04:00:00 +0000', '%Y-%m-%d %h:%i:%s +Z')

抛出错误格式无效:“2021-05-22 04:00:00 +0000”在“0000”处格式错误

任何帮助将不胜感激,谢谢!

【问题讨论】:

    标签: sql timezone presto timezone-offset timestamp-with-timezone


    【解决方案1】:

    这行得通!:

    SELECT PARSE_DATETIME('2017-03-29 10:32:28 +0000', 'YYYY-MM-dd HH:mm:ss Z');
    

    输出:2017-03-29 10:32:28.000 (timestamp_tz)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-22
      • 2021-12-22
      • 1970-01-01
      • 2018-12-18
      • 1970-01-01
      • 2021-09-22
      • 1970-01-01
      相关资源
      最近更新 更多