+ Reply to Thread
Results 1 to 15 of 15

Compare two dates and convert to age

  1. #1
    Registered User
    Join Date
    06-03-2009
    Location
    N.Ireland
    MS-Off Ver
    Excel 2003
    Posts
    76

    Compare two dates and convert to age

    I am trying to compare the difference between to dates (a person dob and the date of an activity they have carried out and then output the age of the person when this activity was done:

    for example:

    activity date: 08/01/2008
    dob: 05/12/2007

    I want to output the person age in months and years, can anyone help?
    Last edited by PRodgers; 07-17-2009 at 01:28 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Compare two dates and convert to age

    Try Datedif()

    =Datedif(A1,B1,"y")&" years "&Datedif(A1,B1,"ym")&" months"
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Compare two dates and convert to age

    Does this help?

    =DATEDIF(BirthDate,activitydate,"y")&" years "&DATEDIF(BirthDate,activitydate,"ym")&" months "&DATEDIF(BirthDate,activitydate,"md")&" days"

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Compare two dates and convert to age

    Damn, the Lone ranger's dad beat me at it !

  5. #5
    Registered User
    Join Date
    06-03-2009
    Location
    N.Ireland
    MS-Off Ver
    Excel 2003
    Posts
    76

    Re: Compare two dates and convert to age

    Thanks guys, appreciate that, it worked brilliantly both ways.

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Compare two dates and convert to age

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  7. #7
    Registered User
    Join Date
    06-03-2009
    Location
    N.Ireland
    MS-Off Ver
    Excel 2003
    Posts
    76

    Re: Compare two dates and convert to age

    Guys im having trouble with a couple of dates:

    activity date: 19/06/08
    DOB: 26/11/02

    Im getting "#VALUE!" in the cell:

    formula: =DATEDIF(I4,J4,"y")&" years "&DATEDIF(I4,J4,"ym")&" months"

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Compare two dates and convert to age

    Are those dates entered per your regional settings?

    Ie, maybe they should be month/day/year?

    Also, DOB should be in I4 and activity date in J4

  9. #9
    Registered User
    Join Date
    06-03-2009
    Location
    N.Ireland
    MS-Off Ver
    Excel 2003
    Posts
    76

    Re: Compare two dates and convert to age

    Quote Originally Posted by NBVC View Post
    Are those dates entered per your regional settings?

    Ie, maybe they should be month/day/year?

    Also, DOB should be in I4 and activity date in J4

    Hey,

    Yeah they are regional, i have the date formatted as day/month/year, i have 150 rows of dates.

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Compare two dates and convert to age

    Try selecting the column, go to Data|Text to Columns... skip to 3rd window and select Date from the Column Data format area... then select DMY from drop down next to the DATE

    Click Finish

  11. #11
    Registered User
    Join Date
    06-03-2009
    Location
    N.Ireland
    MS-Off Ver
    Excel 2003
    Posts
    76

    Re: Compare two dates and convert to age

    Quote Originally Posted by NBVC View Post
    Try selecting the column, go to Data|Text to Columns... skip to 3rd window and select Date from the Column Data format area... then select DMY from drop down next to the DATE

    Click Finish
    hey, i changed the date format to dmy format, i still cant get the second row to calculate the years and months between the dates:

    dob = 26/11/02

    activity = 19/06/08

    I get #value in the row.


    The first row works with the date:

    dob = 12/05/07
    activity = 08/01/08

    this outputs 0 years 7 months

  12. #12
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Compare two dates and convert to age

    Can you post a sample workbook (no confidential data)

  13. #13
    Registered User
    Join Date
    06-03-2009
    Location
    N.Ireland
    MS-Off Ver
    Excel 2003
    Posts
    76

    Re: Compare two dates and convert to age

    Sample workbook:
    Attached Files Attached Files
    Last edited by PRodgers; 07-17-2009 at 10:57 AM.

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Compare two dates and convert to age

    Like I had guessed, your dates in column A were not actually dates...

    I did what I had said using the TextToColumns and now get results as attached.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    06-03-2009
    Location
    N.Ireland
    MS-Off Ver
    Excel 2003
    Posts
    76

    Re: Compare two dates and convert to age

    Quote Originally Posted by NBVC View Post
    Like I had guessed, your dates in column A were not actually dates...

    I did what I had said using the TextToColumns and now get results as attached.
    NBVC thankyou very much for your help, i really appreciate it
    Last edited by NBVC; 07-17-2009 at 01:30 PM. Reason: corrected spelling of my name!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1