Home » SQL & PL/SQL » SQL & PL/SQL » calculate age in year, month and days
calculate age in year, month and days [message #207604] Wed, 06 December 2006 03:26 Go to next message
iriswancy
Messages: 17
Registered: December 2005
Location: Malaysia
Junior Member
Hi..

Here's the function i have created to calculate age in year(s) and month(s)...

(dob_incorp_date in date)
return varchar2
as
yrs number(3);
mnths number(2);
str varchar2(20);
Begin
yrs:=floor(months_between(sysdate,dob_incorp_date)/12);
mnths:=mod(months_between(sysdate,dob_incorp_date),12);
str:=yrs||' '||'years'||' '|| mnths ||' '||'months';
return str;
end;

As above function, any idea how to include to calculate the age in day(s) also?

Pls help.

Thanks & Regards,
Iris
Re: calculate age in year, month and days [message #207618 is a reply to message #207604] Wed, 06 December 2006 04:47 Go to previous message
scorpio_biker
Messages: 154
Registered: November 2005
Location: Kent, England
Senior Member
Hi,

This posting might help if you adapt it for your function

http://www.orafaq.com/forum/m/11452/78730

HTH
Previous Topic: SQL Server to Oracle
Next Topic: creating a dsn problem - microsoft odbc for oracle
Goto Forum:
  


Current Time: Thu Dec 26 10:00:47 CST 2024