如何解决函数 datediff(未知,没有时区的时间戳,没有时区的时间戳)不存在
how to resolve function datediff(unknown, timestamp without time zone, timestamp without time zone) does not exist
SELECT "reviewedAt", "createdAt", DATEDIFF('hour', "createdAt"::timestamp, "reviewedAt"::timestamp) as hours_approved from "yadda$prod"."Application"
error [42883] ERROR: function datediff(unknown, timestamp without time zone, timestamp without time zone) does not exist 提示:没有函数匹配给定的名称和参数类型。您可能需要添加显式类型转换。排名:36
试试这个:
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"
还有一个解决方案:
SELECT
"reviewedAt",
"createdAt",
(EXTRACT(EPOCH FROM "reviewedAt"::timestamp - "createdAt"::timestamp)/3600)::int2 AS hours_approved
FROM "yadda$prod"."Application";
SELECT "reviewedAt", "createdAt", DATEDIFF('hour', "createdAt"::timestamp, "reviewedAt"::timestamp) as hours_approved from "yadda$prod"."Application"
error [42883] ERROR: function datediff(unknown, timestamp without time zone, timestamp without time zone) does not exist 提示:没有函数匹配给定的名称和参数类型。您可能需要添加显式类型转换。排名:36
试试这个:
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"
还有一个解决方案:
SELECT
"reviewedAt",
"createdAt",
(EXTRACT(EPOCH FROM "reviewedAt"::timestamp - "createdAt"::timestamp)/3600)::int2 AS hours_approved
FROM "yadda$prod"."Application";