Home > DeveloperSection > Forums > age calculation in C#
benjamin richards
benjamin richards

Total Post:4

Posted on    February-04-2013 2:38 AM

 C# C# 

 1 Reply(s)
 2125  View(s)
Rate this:

Hi Expert!

I'm working on windows application with C# and I want to calculate age (year) from today's date. Please help me!

Thanks in advance


Total Post:604

Posted on    February-04-2013 5:53 AM

Hi Benjamin Richards!

  You can use this way!

  // Get current date
  DateTime today = DateTime.Today;
  // Assing given date
  DateTime bday = DateTime.Parse("12/05/1986 12:00:00 AM");
  // Get difference between two date
  int age = today.Year - bday.Year;

Modified On Feb-04-2013 05:55:08 AM

Don't want to miss updates? Please click the below button!

Follow MindStick