Tuesday, 6 November 2012

How to convert dob to age in oracle


Select
Trunc(months_between(sysdate,dob)/12) YEAR,
Trunc(Mod(months_between(sysdate,dob),12)) MONTH,
Trunc(sysdate - add_months(dob,Trunc(months_between(sysdate,dob)/12)*12
         +Trunc(mod(months_between(sysdate,dob),12)))) DAYS
From (Select to_date(:P_Date,'DD-MON-YYYY') dob from Dual);

2 comments: