Home  »  Code Snippets  »  C#.Net  »

How to calculate age from date of birth in C#.Net

 Posted By : Manoranjan SahooPosted Date : 13/11/2010 11:00:07 PM Category : C#.Net Points : 2

use below code to find age from date of birth :

using System.Globalization;
IFormatProvider culture = new CultureInfo("en-US", true);
string dob = "24/05/1980";
int age = DateTime.Now.Subtract(DateTime.ParseExact(dob, "dd/MM/yyyy", culture, DateTimeStyles.NoCurrentDateDefault)).Days/365;

No responses found for this thread. Be the first to respond this thread.
Post Reply
Login to post Response.