anyone know how to get the age based on a date(birthdate)
im thinking of something like this
string age = DateTime.Now.GetAccurateAge();
@if (Model.CF_DateOfBirth.HasValue)
{
var today = DateTime.Today;
var months = DateTime.Today;
var age = today.Year - Model.CF_DateOfBirth.Value.Year;
var mons = months.Month - Model.CF_DateOfBirth.Val`enter code here`ue.Month;
if (Model.CF_DateOfBirth > today.AddYears(-age) && Model.CF_DateOfBirth>months.AddMonths(-mons))
{
age--; mons--;
}
Date of birth: @Convert.ToDateTime(Model.CF_DateOfBirth).ToShortDateString().ToString() ( @ageYears @mons Months)
}