Skip to content

Instantly share code, notes, and snippets.

@gavilanch
Created Jul 25, 2019
Embed
What would you like to do?
public static class DateUtilities
{
public static int CalculateAge(DateTime birthdate)
{
var age = DateTime.Today.Year - birthdate.Year;
var temp = new DateTime(DateTime.Today.Year,
birthdate.Month, birthdate.Day);
if (temp > DateTime.Today)
{
age--;
}
return age;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment