postgresqldatediff

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


Solution

  • 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"