Reputation: 13
I have a case statement that returns a date;
case when (ma.first_active_date is not null or ma.first_deemed_date is not null)
then (least(nvl(ma.first_active_date,sysdate),nvl(ma.first_deemed_date,sysdate)))
else (ma.status_date) end djf
How can i then calculate a count of years between the returned date and the sysdate?
Upvotes: 1
Views: 284
Reputation: 726639
You should be able to simply plug in your case statement into an expression, without the djf
alias, of course:
((case when (ma.first_active_date is not null or ma.first_deemed_date is not null)
then (least(nvl(ma.first_active_date,sysdate),nvl(ma.first_deemed_date,sysdate)))
else (ma.status_date) end) - sysdate) diff_from_sysdate
Upvotes: 0