|
|
|
You can quickly evaluate the age of a person using the following function: |
Click here to copy the following block | Function Age(BirthDate As Date, Optional CurrentDate As Variant) As Integer If IsMissing(CurrentDate) Then CurrentDate = Now Age = Year(CurrentDate) - Year(BirthDate) End Property |
If you omit the second argument, the age is evaluate at the current time, but specifying it you can evaluate the age at any given date. The above function, however, evaluates the age of a person in a "informal" way. To see what this means, run the following code: |
It is evident that the function actually returns the age of the person on his/her birthday in the current year, but the actual age could be less than this value. To evaluate the "exact" age, use the following variant: |
Click here to copy the following block | Function Age(BirthDate As Date, Optional CurrentDate As Variant, _ Optional ExactAge As Boolean) As Integer If IsMissing(CurrentDate) Then CurrentDate = Now Age = Year(CurrentDate) - Year(BirthDate) If ExactAge Then If DateSerial(Year(CurrentDate), Month(BirthDate), _ Day(BirthDate)) > CurrentDate Then Age = Age - 1 End If End If End Property |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|