CSharp examples for System:DateTime Year
Age In Years
using System;/*from w w w. ja va2s . c o m*/ public class Main{ public static int AgeInYears(DateTime birthdate) { int years = DateTime.Now.Year - birthdate.Year; if (DateTime.Now.Month < birthdate.Month || (DateTime.Now.Month == birthdate.Month && DateTime.Now.Day < birthdate.Day)) years--; return years; } }