Rhayezelle
Member
could you help me how to compute an exact age of a person using the format date of mm/dd/yy... in vb.net, i was trying to code it but the result was not the exact age of the person.. please help me... 
Dim birthdate As DateTime = DateTime.Parse("05/13/1975")
Dim interval As TimeSpan = DateTime.Now - birthdate
Dim years As Integer = interval.Days / 365
Dim days As Integer = interval.Days Mod 365
Console.WriteLine("This person is old " & years & " years and " & days & " days")
You can use many different methods for finding the age. for instance you can use TimeSpan Structure (System)
VB.NET:Dim birthdate As DateTime = DateTime.Parse("05/13/1975") Dim interval As TimeSpan = DateTime.Now - birthdate Dim years As Integer = interval.Days / 365 Dim days As Integer = interval.Days Mod 365 Console.WriteLine("This person is old " & years & " years and " & days & " days")
Dim bday As DateTime = DateTime.Parse("10/01/1983")
Dim today As DateTime = DateTime.Now
Dim years As Integer = today.Year - bday.Year ''take the difference in year
Dim days As Integer = today.DayOfYear - bday.DayOfYear ''get the difference in days
''If today is before the birthday then we subtract 1 from the years and add that year (365) to the days
If days < 0 Then
years -= 1
days += 365
End If
Console.WriteLine("You are {0} year/s and {1} day/s old", years, days)
lordofduct said:If you don't want to deal with my post because it's just to much. Then don't read it.
It is not about the opinions Rhayezelle.
This guy seems to be good at telling stories. But who of you come here for reading somone's stories?
I am pretty certain that people come here for help and nothing but help. Period!
He made it to sound very theatrical but it's not. Especially because of the fact that it can be easily found on Internet. Click here and see for yourself Let me google that for you
In addition i hate when someone search for a pre-written solution or partial solution and present it like a own code. Copy and paste programming - Wikipedia, the free encyclopedia
Does this seems familiar to you? http://www.developerfusion.com/code/4671/calculate-age/ (By James Crowley, published on 20 Feb 2005). It looks like a very good starting point indeed
However it seems that he is right about one thing: