I want to substract 2 dates to get number of days, which I will divide later by number of days in year. The INC_DATE is in date format, the to_date function is used to define date from 1.1. of the selected year. Year 2015 is defined because the output value (days) should not take year from inc_date, therefore even if inc_date has different years, I have defined it as default year 2015.
case when (extract(month from inc_date)=2 and extract(day from inc_date)=29) then
(to_date(inc_date,’2015/mm/dd’) - to_date (’2015-01-01’,’yy/mm/dd’))/366 else
(to_date(inc_date,’2015/mm/dd’) - to_date (’2015-01-01’,’yy/mm/dd’))/365
end as E1