I see that this has been asked many times. A lot of people have answered, but i haven't been able to make it work.
This is the code I got from my searches:
public static int CalculateAge(DateTime birthDate)
{
DateTime now = DateTime.Today;
int years = now.Year - birthDate.Year;
if (now.Month < birthDate.Month || (now.Month == birthDate.Month && now.Day < birthDate.Day))
--years;
return years;
}
How do I supply the birth date from a TextBox?
Im using Jquery calender to supply date into a TextBox3 in dd-mm-yy format..
Now I want to calculate age from the supplied date and then on a button click to save in the DB..
I get the save on DB part, but how do I insert TextBox value into the code above and then use years to save it on my button click event?