0

I'm trying to compare the column: LastUpdated with todays date in days, rounded to 1 decimal place. I keep getting the error

ERROR at line 4:
ORA-00904: "DATEDIFF": invalid identifier

Any ideas?

SELECT
DISTINCT "AppName",
"ApprovedForRelease",
DATEDIFF(DAY,"LastUpdated",GETDATE())  AS "DaySinceUpdated" 
FROM BR_APP
WHERE "ApprovedForRelease" = 'Y';
Gentian Gashi
  • 331
  • 2
  • 13

1 Answers1

2

In Oracle, you can use subtraction. To get the dates between, truncate off the time:

SELECT DISTINCT "AppName", "ApprovedForRelease",
       (TRUNC(sysdate) - TRUNC("LastUpdated"))  AS "DaySinceUpdated" 
FROM BR_APP
WHERE "ApprovedForRelease" = 'Y';

The code you have used is based on SQL Server.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786