When I enter a dateadd or datediff code i get this error all the time "ORA-00904 "DATEADD" INVALID IDENTIFIER."

Frank picture Frank · Mar 19, 2015 · Viewed 17.1k times · Source

I have a university project and I have a patient table with admission and discharge date attributes. I need to delete records that are older than 7 years, I used the following code :

delete from patient
where dis_date >= datedadd(yy,-7,getdate());

I get the error

"ORA-00904: "DATEADD" invalid identifier"

. It's the same with the DATEDIFF function. Any alternatives please?

Answer

Rahul Tripathi picture Rahul Tripathi · Mar 19, 2015

You may try this:

DELETE FROM patient
  WHERE dis_date  < SYSDATE - INTERVAL '7' YEAR;

There is no function named as DATEADD in Oracle.