I need a SQL statement to identify all rows that are more than
two years old and set my status flag based on my DATE column.
Is there a minus_years function in Oracle SQL?
If not, how can I make a SQL function to subtract two years in my
Can I use the add_years built-in function (BIF)?
Answer: Because Oracle is so flexible, there are several ways to
satisfy your request using
Also note here on how to do
Oracle arithmetic functions and you can also use date functions
This primitive example demonstrates the concept, but it will not
always work because leap years will have 366 days:
trunc(sysdate) < myrow_date -(365*2)
A correct solution would use the add_years BIF, something
trunc(sysdate) < (myrow_date - add_years(myrow_date,2));