age calculation in C#

Total Post:4


 2747  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

  1. Re: age calculation in C#

    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


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.