Home » SQL & PL/SQL » SQL & PL/SQL » How many
How many [message #22107] Tue, 24 September 2002 03:50 Go to next message
Rajendra
Messages: 23
Registered: September 2000
Junior Member
hai
Can i get the total age of a person in one sql.
I will pass date of birth. The output will be total years,total month and total days.
Re: How many [message #22110 is a reply to message #22107] Tue, 24 September 2002 05:00 Go to previous message
Jon
Messages: 483
Registered: May 2001
Senior Member
SQL> select
2 trunc(months_between(sysdate,to_date('02/07/1950','mm/dd/yyyy'))/12) years,
3 mod(trunc(months_between(sysdate,to_date('02/07/1950','mm/dd/yyyy'))),12) months,
4 trunc(sysdate - add_months(to_date('02/07/1950','mm/dd/yyyy'),trunc( months_between( sysdate, t
o_date('02/07/1950','mm/dd/yyyy') ) ))) days
5 from dual;

YEARS MONTHS DAYS
--------- --------- ---------
52 7 17
Previous Topic: Tablespace
Next Topic: create a procedure dynamic in another procedure???
Goto Forum:
  


Current Time: Wed May 08 04:37:54 CDT 2024