【问题标题】:how to resolve function datediff(unknown, timestamp without time zone, timestamp without time zone) does not exist如何解决函数 datediff(未知,没有时区的时间戳,没有时区的时间戳)不存在
【发布时间】:2020-04-24 03:48:12
【问题描述】:
SELECT "reviewedAt", "createdAt", DATEDIFF('hour', "createdAt"::timestamp, "reviewedAt"::timestamp) as hours_approved from "yadda$prod"."Application" 

错误 [42883] 错误:函数 datediff(未知,没有时区的时间戳,没有时区的时间戳)不存在 提示:没有函数与给定的名称和参数类型匹配。您可能需要添加显式类型转换。位置:36

【问题讨论】:

    标签: postgresql datediff


    【解决方案1】:

    试试这个:

    SELECT 
    "reviewedAt",
    "createdAt",
    DATE_PART('day', "reviewedAt"::timestamp - "createdAt"::timestamp) * 24 + DATE_PART('hour', "reviewedAt"::timestamp - "createdAt"::timestamp) AS hours_approved 
    FROM "yadda$prod"."Application"
    

    【讨论】:

      【解决方案2】:

      另一种解决方案:

      SELECT 
          "reviewedAt",
          "createdAt",
          (EXTRACT(EPOCH FROM "reviewedAt"::timestamp - "createdAt"::timestamp)/3600)::int2 AS hours_approved
      FROM "yadda$prod"."Application";
      

      【讨论】:

        猜你喜欢
        • 2018-06-27
        • 1970-01-01
        • 1970-01-01
        • 2017-04-25
        • 2011-12-14
        • 1970-01-01
        • 2017-10-06
        • 2014-02-12
        • 1970-01-01
        相关资源
        最近更新 更多