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:wave:
thx still need some help though
the first post doesn't work becaus its just using the integer division operator and so its rounding the numbers accordingly and spitting out a closer number but it can still get the wrong one(believe me when I say was very hopefull that it would be that easy)
However I looked at the second one and I am not sure how to implement it.
My level of programming is so far fairly limited to the btn calc button. So I put the whole thing into the btncalc section of my code and I am getting some large decimal returns.
I'm not quite seeing how to make it work
sorry to be a bother but still in need of some guidance.
thx in advance
Warpig