5
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

ChatGPT
  • 5,334
  • 12
  • 50
  • 69

2 Answers2

5

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"
nunoq
  • 550
  • 2
  • 7
1

One more solution:

SELECT 
    "reviewedAt",
    "createdAt",
    (EXTRACT(EPOCH FROM "reviewedAt"::timestamp - "createdAt"::timestamp)/3600)::int2 AS hours_approved
FROM "yadda$prod"."Application";
Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39