Hello Everyone and thanks for your help in advance. I am working on an application that needs to determine whether a person has passed their 18th birthday. I tried the following code:
However, when I run this code today (2/16/2012), it returns the number 18. Obviously, this person's 18th birthday has not yet passed so this code will not work. I'm not sure what the problem is. Any help would be greatly appreciated.
kmcnet
Participant
1090 Points
652 Posts
Calculating Age
Feb 16, 2012 09:28 PM|LINK
Hello Everyone and thanks for your help in advance. I am working on an application that needs to determine whether a person has passed their 18th birthday. I tried the following code:
Dim DOB As Date = "3/25/1994"
Dim TodaysDate As Date = Now().ToShortDateString
YearsOld = DateDiff(DateInterval.Month, DOB, TodaysDate)
However, when I run this code today (2/16/2012), it returns the number 18. Obviously, this person's 18th birthday has not yet passed so this code will not work. I'm not sure what the problem is. Any help would be greatly appreciated.