+ Reply to Thread
Results 1 to 12 of 12

formula to calculate exact years, months and days seperately between two dates?

  1. #1
    Registered User
    Join Date
    01-12-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    5

    formula to calculate exact years, months and days seperately between two dates?

    I m not able to calculate exact number of years months and days seperately between to dates. Pls help.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: formula to calculate exact years, months and days seperately between two dates?

    Can you give an example? With start date in A2 and end date in B2 you can use DATEDIF to give years, months and days altogether

    =DATEDIF(A2,B2,"y")&" years "&DATEDIF(A2,B2,"ym")&" months "&DATEDIF(A2,B2,"md")&" days"

    or do you want those in separate cells? If so just use each DATEDIF element on its own
    Audere est facere

  3. #3
    Registered User
    Join Date
    01-12-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: formula to calculate exact years, months and days seperately between two dates?

    Thanx for the formula

    I had pasted the formula suggested by you i.e.

    =DATEDIF(B2,A2,"y")&" years "&DATEDIF(B2,A2,"ym")&" months "&DATEDIF(B2,A2,"md")&" days"

    but unfortunately result was :

    #NUM!

    Can you kindly attach a excel sheet with an example, say A2 : 02-06-1976 & B2 : 01-01-2013

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: formula to calculate exact years, months and days seperately between two dates?

    Are the dates you are working with, actually dates/values, or text that looks like dates? test with =isnumber(cell-ref) FALSE means text
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    01-12-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: formula to calculate exact years, months and days seperately between two dates?

    I had tested with =isnumber(cell-ref) result is TRUE.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: formula to calculate exact years, months and days seperately between two dates?

    click on the cell with the formula in it, and press F2. look at where the references are pointing. Are they all where they need to be, based on where you're data is? If not, adjust as needed.

    If this still doesnt work, i would suggest you upload a sample work book, (all sensitive data removed), showing what data you are working with, a few examples of what your expected outcome is, and how you arrived at that
    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: formula to calculate exact years, months and days seperately between two dates?

    Quote Originally Posted by suweg View Post
    but unfortunately result was :

    #NUM!
    #NUM! error implies that A2> B2, in DATEDIF(A2,B2,"y") and similar A2 needs to be the earlier of the two dates

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: formula to calculate exact years, months and days seperately between two dates?

    Thanks DDL, I didnt think of that

  9. #9
    Registered User
    Join Date
    01-12-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: formula to calculate exact years, months and days seperately between two dates?

    I had attached the file (gratuity calculator.xls)
    Attached Files Attached Files

  10. #10
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: formula to calculate exact years, months and days seperately between two dates?

    Note that in DATEDIF (earlier date, later date,...)
    Quang PT

  11. #11
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: formula to calculate exact years, months and days seperately between two dates?

    as pointed out it needs to be
    =DATEDIF(H3,I3,"y")&" years "&DATEDIF(H3,I3,"ym")&" months "&DATEDIF(H3,I3,"md")&" days"
    gives
    30 years 5 months 8 days
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  12. #12
    Registered User
    Join Date
    01-12-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: formula to calculate exact years, months and days seperately between two dates?

    Thanx to you all. It worked. Thanx to all once again.

+ 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