【问题标题】:Extracting Time from Timestamp in Redshift从 Redshift 中的时间戳中提取时间
【发布时间】:2018-04-17 11:42:06
【问题描述】:

我正在使用 Redshift,并希望从时间戳中提取时间。

这是时间戳:2017-10-31 23:30:00

我只想把时间设为 23:30:00

我尝试使用cast(the_timestamp_column as time),但遇到此错误消息:

error message: Function ""time"(timestamp without time zone)" not supported.

【问题讨论】:

    标签: sql amazon-redshift


    【解决方案1】:

    使用 to_char 和适当的格式掩码来提取时间戳的时间部分:

    select to_char(the_timestamp_column, 'HH24:MI:SS')
    from your_table;
    

    Demo

    【讨论】:

    • 非常感谢您的快速回复 =)
    • 我找了一个小时。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-10
    • 2016-08-10
    • 1970-01-01
    • 1970-01-01
    • 2018-07-18
    • 2021-02-18
    • 1970-01-01
    相关资源
    最近更新 更多