AGE CALCULATION IN C#

benjamin richards

Total Post:4

Points:28
Posted by  benjamin richards
C# 
C#
 2241  View(s)
Ratings:
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. AVADHESH PATEL

    Post:604

    Points:4228
    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!