Hello,
I have nullable Datetime and I cannot calculate age. Please help.
public static int GetPersonAge(DateTime? birthDay, DateTime endDate)
{
int years = endDate.Year - birthDay.Year;
if (birthDay.Month > endDate.Month || (birthDay.Month == endDate.Month &&
birthDay.Day > endDate.Day))
years--;
return years;
}
Thanks
What I have tried:
Stackoverfllow, MSD Forum