I am creating one query. In that query i want minus date from system date. My table is like below.
Table Name : Employee
---------------------
ID
NAME
JOINDATE
I am writing this query to fetch my result
SELECT * FROM SS.EMPLOYEE WHERE (sysdate - JOINDATE)='05-Ded-11'
This throws the following error:
SQL Error: ORA-00920: invalid relational operator
So how to do this???If anyone knows than please help me.
In Oracle date arithmetics, subtracting two dates results in the number of days between the two dates:
Your
WHEREclause is therefore incorrect to Oracle since it cannot compare a number to a date. What exactly do you want to express with this comparison?If you want to filter all dates before a given date, just compare the two dates:
If you want to select all rows that are in a given interval, you can use multiple comparisons or the operator
BETWEEN:Update
The number of months between two dates is given by the function
MONTHS_BETWEEN. You would compare the result of this function to a number (of months).