Click here to Skip to main content
13,092,310 members (58,369 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Co-ordinates i want to solution that user give his/her DOB(Date Of Birth) and he/she want to see his/her actual age according to current date..... how can i get actual age format on(dd/mm/yy) subtracted from the current date...
plz i am seeking ur appreciation.
Posted 1-Aug-12 4:00am
Wes Aday 1-Aug-12 10:07am
You mean like the TimeSpan class?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

try the code inside method. You can test it in console application
class Program
        static void Main(string[] args)
            DateTime DOB = Convert.ToDateTime("1988-08-02");
            DateTime now = DateTime.Today;
            int age = now.Year - DOB.Year;
            if (DOB > now.AddYears(-age))
            int month = now.Month - DOB.Month;
            int datediff = 0;
            int days = now.Day - DOB.Day;
            while (days < 0)
                datediff += 1;
                days += 1;
            string str = (31 - datediff) + "/" + month + "/" + age;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 1 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100