英文:
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 Hint: No function matches the given name and argument types. You might need to add explicit type casts. Position: 36"
英文:
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 Hint: No function matches the given name and argument types. You might need to add explicit type casts. Position: 36
答案1
得分: 5
尝试这个:
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"
英文:
Try This:
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
得分: 1
以下是翻译好的部分:
另一种解决方案:
选择
"reviewedAt",
"createdAt",
(提取("reviewedAt" :: timestamp - "createdAt" :: timestamp的时间差的秒数/3600)::int2 AS hours_approved
从 "yadda$prod"."Application";
英文:
One more solution:
SELECT
"reviewedAt",
"createdAt",
(EXTRACT(EPOCH FROM "reviewedAt"::timestamp - "createdAt"::timestamp)/3600)::int2 AS hours_approved
FROM "yadda$prod"."Application";
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论