【问题标题】:Can't extract time from timestamp Postgres无法从时间戳 Postgres 中提取时间
【发布时间】:2018-02-02 13:17:03
【问题描述】:

您好,我正在尝试从 Postgres 中的时间戳中提取时间

SELECT extract(time from '2000-01-01 01:12:00'::timestamp)

结果应该是: 01:12:00

看起来那个时间不是提取的有效参数。对吗?

【问题讨论】:

    标签: postgresql datetime time timestamp


    【解决方案1】:
    select '2000-01-01 01:12:00'::timestamp::time
    

    【讨论】:

      【解决方案2】:

      试试这个:

      s=# SELECT cast ('2000-01-01 01:12:00'::timestamp as time);
         time
      ----------
       01:12:00
      (1 row)
      

      不提取 - 那么,您可能想要使用 cast

      是的 - https://www.postgresql.org/docs/current/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT

      time 不是有效的 aprt

      【讨论】:

        猜你喜欢
        • 2015-01-10
        • 2016-08-10
        • 1970-01-01
        • 2021-02-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-04-17
        • 1970-01-01
        相关资源
        最近更新 更多