Getting age by birthdate?

buggiez

Member
Joined
Feb 7, 2006
Messages
18
Location
Singapore
Programming Experience
1-3
Dear all,
any1 know how to determine the current age of a person just by the data of a birthdate in the database? (lets say age is not stored in the database)

i guess that i will have to take today's date and minus the birthdate, but i dont know how to do so in asp.net..

hope any1 will help..

thanks in advance =)




valerie
 
What do you mean by "age" exactly? Do you just want the number years? If so:
VB.NET:
Dim ageInYears As Integer = Date.Today.Year - dob.Year

If Date.Today.DayOfYear < dob.DayOfYear Then
    'The current year is not complete.
    ageInYears -= 1
End If
You could also use the DateDiff function but I don't like Runtime functions in general.
 
Back
Top