How to calculate exact age [message #527976] |
Fri, 21 October 2011 02:20  |
qanita786
Messages: 229 Registered: May 2007 Location: PAKISTAN
|
Senior Member |
|
|
How to calculate exact age for example my date of birth is 10-04-1972 and today current date is 21-10-2011 so i want to calculate age how many years, how many months and how many days
Regards
Faheem
|
|
|
|
|
Re: How to calculate exact age [message #528213 is a reply to message #528122] |
Sun, 23 October 2011 03:07   |
ranamirfan
Messages: 535 Registered: January 2006 Location: Pakistan / Saudi Arabia
|
Senior Member |

|
|
Dear,
Try it.
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)))) DAY
From (Select to_date('01041977','DDMMYYYY') dob From Dual);
As a Result.
YEAR MONTH DAY
---------------------- ---------------------- ---------------------
34 6 22
Regards,
Irfan
[Updated on: Sun, 23 October 2011 03:28] by Moderator Report message to a moderator
|
|
|
|
|
Re: How to calculate exact age [message #529013 is a reply to message #528217] |
Fri, 28 October 2011 03:25   |
qanita786
Messages: 229 Registered: May 2007 Location: PAKISTAN
|
Senior Member |
|
|
that works very well if i know date of birth but my problem is how to calculate age if any body tell me that his age
is 27.50 years than how to calculate date of birth
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)))) DAY
From (Select to_date('01041977','DDMMYYYY') dob From Dual);
|
|
|
|
Re: How to calculate exact age [message #529015 is a reply to message #529013] |
Fri, 28 October 2011 03:51   |
flyboy
Messages: 1903 Registered: November 2006
|
Senior Member |
|
|
qanita786 wrote on Fri, 28 October 2011 10:25that works very well if i know date of birth but my problem is how to calculate age if any body tell me that his age
is 27.50 years than how to calculate date of birth
Will he really tell you it with precision of 1 day (that is 0.00273224 or 0.002739726 year in 366/365 days' year)? Or even more precisely (hour/minute)?
Maybe you should firstly exactly define, what that fraction means and then convert it to that unit(s) (days/days+months/whatever).
|
|
|
Re: How to calculate exact age [message #529018 is a reply to message #529013] |
Fri, 28 October 2011 04:00   |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
Quote:that works very well if i know date of birth but my problem is how to calculate age if any body tell me that his age
is 27.50 years than how to calculate date of birth
Then why did you say in your first post:
Quote:How to calculate exact age for example my date of birth is 10-04-1972 and today current date is 21-10-2011 so i want to calculate age how many years, how many months and how many days
i.e. the opposite of what you are now saying that your problem is.
I have a feeling that you are still not giving us the full details of your actual requirements. Can you please be more specific as to what you actually need.
|
|
|
|
|
|
|
|
|
Re: How to calculate exact age [message #529119 is a reply to message #529117] |
Fri, 28 October 2011 14:22   |
qanita786
Messages: 229 Registered: May 2007 Location: PAKISTAN
|
Senior Member |
|
|
dear this is demand by a hospital when we asked age from patient they tell us 26.50 years and we have not enough time to calculate date of birth dear swan its not silly its public demand so try to solve issue
|
|
|
|
Re: How to calculate exact age [message #529122 is a reply to message #529119] |
Fri, 28 October 2011 14:25   |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
It would be far more sensible to ask the person's date of birth then rather than their age. If the don't know their date of birth then how on earth can you expect them to know their eact age? You claim makes no sense and apart from that, you have been given the tools that you require to answer the problem, all you need to do is use your head a little and actually think about the problem
|
|
|
Re: How to calculate exact age [message #529124 is a reply to message #529119] |
Fri, 28 October 2011 14:27   |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
And on a similar vein, yes it is silly to expect to be able to accurately calculate someone's date of birth from what will almost certainly be a very rough estimate of their age.
|
|
|
|
|
|
|
Re: How to calculate exact age [message #529134 is a reply to message #529119] |
Fri, 28 October 2011 15:03   |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
qanita786 wrote on Fri, 28 October 2011 15:22dear this is demand by a hospital when we asked age from patient they tell us 26.50 years and we have not enough time to calculate date of birth dear swan its not silly its public demand so try to solve issue
And you expect a patient to calculate their age for you to be bale to use accurately in an equation?
Do you expect someone who is 35 years and 42 days old to say "I am 35.115068493 years old" or for someone to even know how many days past their birthday they are?
This is ridiculous, not silly.
[Updated on: Fri, 28 October 2011 15:05] Report message to a moderator
|
|
|
|
|
|
How to calculate exact age [message #622926 is a reply to message #527976] |
Tue, 02 September 2014 02:33   |
 |
mastansky@gmail.com
Messages: 13 Registered: July 2013 Location: INDIA
|
Junior Member |

|
|
Select trunc(months_between(sysdate,dob)/12) year,
trunc(mod(months_between(sysdate,dob),12)) month,
trunc(Add_Months(sysdate,-Trunc(months_between(sysdate,dob)))-dob) DAY
From (Select to_date('19052014','DDMMYYYY') dob From Dual)
/
Lalit : I formatted your code and added code tags, see the difference now :
SELECT Trunc(Months_between(SYSDATE, dob) / 12)
year,
Trunc(MOD(Months_between(SYSDATE, dob), 12))
month,
Trunc(Add_months(SYSDATE, -Trunc(Months_between(SYSDATE, dob))) - dob)
DAY
FROM (SELECT To_date('19052014', 'DDMMYYYY') dob
FROM dual)
/
[Updated on: Tue, 02 September 2014 02:52] by Moderator Report message to a moderator
|
|
|
|
Re: How to calculate exact age [message #622944 is a reply to message #622926] |
Tue, 02 September 2014 06:37  |
 |
Michel Cadot
Messages: 68765 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
What is your goal to answer to a very old topic that has been answered?
What does your (bad formatted) query add to the previous answers?
|
|
|