I am using Oracle DB and trying to find the date difference in years.
I googled and find out I can use DateDiff function.
When I am using this function:
select datediff(year, date_1, date_2) as Age_Diff
from employee
I am getting an error
ORA-00904: "DATEDIFF": invalid identifier.
Please suggest what is wrong in this.
DATEDIFFis not a function that exists in Oracle.What, exactly, does it mean to you to get a difference between two dates in years? For example, if you are given dates of 2010-04-01 and 2012-01-01, what is the expected output? The difference is 1 year and 9 months so would that be 1.75? Or should we count the number of days in those 9 months vs. the number of days in a year and divide the answer to get something slightly different than 1.75?
My first guess is that you want
If you want to ignore any fractional part of a year