how to resolve function datediff(unknown, timestamp without time zone, timestamp without time zone) does not exist

huangapple go评论94阅读模式
英文:

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"

英文:
  1. 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

尝试这个:

  1. SELECT
  2. "reviewedAt",
  3. "createdAt",
  4. DATE_PART('day', "reviewedAt"::timestamp - "createdAt"::timestamp) * 24 + DATE_PART('hour', "reviewedAt"::timestamp - "createdAt"::timestamp) AS hours_approved
  5. FROM "yadda$prod"."Application"
英文:

Try This:

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

答案2

得分: 1

以下是翻译好的部分:

  1. 另一种解决方案:
  2. 选择
  3. "reviewedAt"
  4. "createdAt"
  5. (提取("reviewedAt" :: timestamp - "createdAt" :: timestamp的时间差的秒数/3600)::int2 AS hours_approved
  6. "yadda$prod"."Application"
英文:

One more solution:

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

huangapple
  • 本文由 发表于 2020年1月6日 23:35:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/59614840.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定