retrieving last two years data from current sysdate

oracle, sql

Solution

How about this?

where stage_end_date >= trunc(sysdate, 'yyyy') - interval '2' year
  and stage_end_date <  trunc(sysdate, 'yyyy');

Problem

Hi i am stuck on an oracle query wherein i want to retrieve data from previous two years based on the current year like this is 2013 so i want to retrieve all records from year 2011 and 2012 i have done the following query but m getting stuck on date formats i am pretty new to oracle here is the query ``` Select to_date(stage_end_date,'yy') Years,SUBPRODUCT Product,sum(OFFER_COUNT) SumCount ,sum(offer_amount)SumAmount from stage_amt and Offer_amount !=0 and to_date(stage_end_date,'yy') between to_char( sysdate, -2 ) and to_char( sysdate) group by to_date(stage_end_date,'yy'),SUBPRODUCT order by Years asc; ``` m getting this error ORA-00932: inconsistent datatypes: expected DATE got NUMBER 00932. 00000 - "inconsistent datatypes: expected %s got %s" can any one help me what to do regards

Original source