public int GetAge(DateTime dob)
{
// Get year diff
int years = DateTime.Now.Year - dob.Year;
// Add year diff to birth day
dob = dob.AddYears(years);
// Subtract another year if its one day before the birth day
if (DateTime.Today.CompareTo(dob) < 0) { years--; }
return years;
}
Thanks
ReplyDeleteThank you for this.
ReplyDelete