【问题标题】:In Redshift, How to cast current_timestamp to timestamp with UTC timezone?在 Redshift 中,如何使用 UTC 时区将 current_timestamp 转换为时间戳?
【发布时间】:2019-11-07 05:37:49
【问题描述】:

这是有效的:

select to_char(current_timestamp AT TIME ZONE 'UTC', 'YYYY-MM-DD HH24:MI:SS OF')

但是当我将它插入到表中时,它会因为这个错误而失败:

42804:列“load_time”是带时区的时间戳类型,但表达式是文本类型

【问题讨论】:

    标签: sql amazon-web-services amazon-s3 amazon-redshift


    【解决方案1】:

    to_char() 函数输出一个文本字符串。

    如果您尝试将其插入TIMESTAMP WITH TIME ZONE 字段,则只需参考:

    current_timestamp AT TIME ZONE 'UTC'
    

    【讨论】:

      猜你喜欢
      • 2013-06-30
      • 1970-01-01
      • 1970-01-01
      • 2019-03-09
      • 2019-06-18
      • 1970-01-01
      • 2020-06-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多