I have a table t with a column "date" which has the type "DATE":
date
2018-10-01
2019-02-03
2020-01-01
2021-01-01
I want to get only entries where CURRENT_DATE / SYSDATE minus 2 years is true. So the result should be (CURRENT_DATE / SYSDATE = "2021-05-01":
date
2019-02-03
2020-01-01
2021-01-01
My code:
SELECT *
FROM t
WHERE YEAR(t.date) >= ADD_YEARS(TRUNC(CURRENT_DATE), -2)
But that gives me the error
Feature not supported: Incomparable Types: DECIMAL(4,0) and DATE!
Using SYSDATE with
SELECT *
FROM t
WHERE YEAR(t.date) >= ADD_YEARS(TRUNC(SYSDATE), -2)
gives the error
Feature not supported: Incomparable Types: DECIMAL(4,0) and DATE!
I tried https://stackoverflow.com/a/28888880/4435175 with
SELECT *
FROM t
WHERE YEAR(t.date) >= add_months( trunc(sysdate), -12*2 )
but that gave me the same error
Feature not supported: Incomparable Types: DECIMAL(4,0) and DATE!