»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books
»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects
»Competition
Community
Winners
Prizes
Write For Us
Members
»Other Resources
Links
Dotnet Resources
|
c# age converterI found this and wanted to share with friends
public static int CalculateAge(DateTime birthDate)
{
// cache the current time
DateTime now = DateTime.Today; // today is fine, don't need the timestamp from now
// get the difference in years
int years = now.Year - birthDate.Year;
// subtract another year if we're before the
// birth day in the current year
if (now.Month < birthDate.Month || (now.Month == birthDate.Month && now.Day < birthDate.Day))
--years;
return years;
}
|
|