Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to calculate age in oracle

685758Sep 9 2011 — edited Sep 9 2011
Hi,

T was trying do calculate age as on todays date in ORACLE but after a lot of brain storming i didn't get it.
Kindly tell me how to calculate age as in years month days.

For ex.. My DOB- 02-feb-1984 so my age should get as 27 Years 2 months 8 days

How to do it.

I tried this
select
TRUNC( months_between( sysdate, TO_DATE('02-02-1984','DD-MM-YYYY') )/12 ) Year,
TRUNC( mod(months_between( sysdate, TO_DATE('02-02-1984','DD-MM-YYYY') ),12) ) Month,
mod(months_between( sysdate, TO_DATE('02-02-1984','DD-MM-YYYY') ),12) /30 Days
from dual

but days are not calculating correctly...

RGds,
PC
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 7 2011
Added on Sep 9 2011
13 comments
5,859 views