Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Age from DOB function 1

Status
Not open for further replies.

JimYellow

Programmer
Nov 3, 2003
13
AU
I am looking for a function that takes a date of birth and returns the persons age

someone must have already written a function for this!
 
Public Function Age(DOB As Date)
Age = Int((Date - DOB) / 365.25)
End Function
 
I suggest a further search, Even within Tek-Tips, you can easily find numerous threads discussing the subject in general. In particular, you should note the issues with the already presented (above) quasi soloution and a number of alternatives which overcome these.




MichaelRed


 
Age = DateDiff("yyyy", DOB, Date) + (Format(DOB, "mmdd") < Format(Date, "mmdd"))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Dob = #10/4/05#
? DateDiff("yyyy", DOB, Date) + (Format(DOB, "mmdd") < Format(Date, "mmdd"))
-1


... but this is just one of the many trips down memory lane ...




MichaelRed


 
OOps, sorry for the typo:
Age = DateDiff("yyyy", DOB, Date) + (Format(DOB, "mmdd") > Format(Date, "mmdd"))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
and poos?

dob = dateAdd("d", 364, date )
? DateDiff("yyyy", DOB, Date) + (Format(DOB, "mmdd") > Format(Date, "mmdd"))
-1

dob = dateAdd("d", date, 364)
? DateDiff("yyyy", DOB, Date) + (Format(DOB, "mmdd") > Format(Date, "mmdd"))
-1



MichaelRed


 
Sorry Michael, but I quite don't understand your last post.
What is a poos ?
My formula is for returning the age of an already born person.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Poos is just being slpooy with spelling OOPS. Seems, to me, that if you are advertising that a procedure return the AGE from the DOB, it should consider the possabilities. Shouldn't it LIMIT the answer? You obviously recognize that the first 364 days (or so) do not constitute a Year(of age), so why would the previous 364 days (or any subsset thereof) constitute a year(of Age)?



MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top