|
-
Nov 22nd, 2004, 01:49 AM
#1
Thread Starter
New Member
Attention anyone who can help with the datediff function
Hi everyone I am hoping somebody can help me...
I have a project due in my VB.net class and I am not seeing what I need in the index files or anywhere else for that matter
What I need specifically is to calculate someones age in years by their exact birthdate
But here is the kicker...When I use this
btnCalc_click....etc...
Privatesub
Dim Date1 As Date = CDate(txtBirthDate.Text)
Dim Date2 As Date = Today
Dim age As Long = DateDiff(DateInterval.Year, Date1, Date2)
lblage.Text = CStr(age)
end sub
it returns the number in years but does not take in to consideration that if the month has not occured yet in our present year then the person is infact not the age that is being displayed in lblage.text
It only counts the years and ignores the days and months
if I change ...(DateInterval.year....) to ...(DateInterval.day...)then it returns a count of the days from the txtbirthdate.text
So basicaly when I enter a date of 12/22/1974
the program returns 30 years when (if your reading this prior to 12/22/2004) It shoud return 29.
This cannot be alowed to continue or there will be chaos throughout the land please help.
I know this is probably a stupid question to the experienced programmers here, but I am hopfull that one of you could take five minutes and shoot me some code that would work
thanks in advance
Warpig
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|