Friday, April 27, 2012

Calculate Age Function




private int CalculateAge(int year, int month, int day)
        {
            int age = 0;
            age = DateTime.Now.Year - year;
            if (DateTime.Now.Month < month)
                age--;
            if (DateTime.Now.Month == month)
            {
                if (DateTime.Now.Day < day)
                    age--;
            }
            return age;
        }

No comments: