+ Reply to Thread
Results 1 to 6 of 6

Forumla to calculate differences in dates

  1. #1
    Registered User
    Join Date
    06-19-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    Cool Forumla to calculate differences in dates

    Hi

    I am trying to find a formula that will calcualte the number of months between 2 dates but, will also take into account some other rules. For example: if the second date has a day of less the 15 it would calculate that month as 0.5 and if the day is over 15 it will calculate the month as a full month.

    Start Date: 01.01.2014
    End Date: 14.06.2014

    Months worked: 5.5

    Start Date: 01.01.2014
    End Date: 15.06.2014

    MOnths worked: 6

    Any help would be really appriciated.

  2. #2
    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,936

    Re: Forumla to calculate differences in dates

    Hi and welcome to the forum

    If you want to include years (if the dates go past 1 year), then use this...
    =IF(DATEDIF(A1,B1,"y")=0,"",DATEDIF(A1,B1,"y")&" years ")&IF(DATEDIF(A1,B1,"ym")=0,"",DATEDIF(A1,B1,"ym")+IF(DATEDIF(A1,B1,"md")<15,0.5,1)&" months ")

    If you dont need the year part, then shorten it to this...
    =IF(DATEDIF(A1,B1,"ym")=0,"",DATEDIF(A1,B1,"ym")+IF(DATEDIF(A1,B1,"md")<15,0.5,1)&" months ")

    Note, the 2nd example you gave only has a 14-day "remainder"
    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

  3. #3
    Registered User
    Join Date
    02-13-2014
    Location
    2829
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Forumla to calculate differences in dates

    I've always just done this for calculating difference in dates:

    (end date/start date)/365.25
    you'll need to format the cell to show a number, the default is a date so you must change it.

  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,936

    Re: Forumla to calculate differences in dates

    Hi and welcome to the forum

    (end date/start date)/365.25
    I think you meant...
    (end date-start date)/365.25

    and / 365 will give you a decimal of a year, not months

    A
    4
    1/1/2014
    5
    6/14/2014
    6
    0.449007529

    A6=(A5-A4)/365.25

  5. #5
    Registered User
    Join Date
    06-19-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Forumla to calculate differences in dates

    Thanks Ford - this worked perfectly!

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Forumla to calculate differences in dates

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Compare column A with B and calculate differences
    By mrcois in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-26-2010, 03:07 PM
  2. Help with forumla to calculate daily targets
    By Climaxgp in forum Excel General
    Replies: 5
    Last Post: 04-09-2009, 08:57 AM
  3. How to calculate Date & Time differences
    By robs in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-04-2005, 11:22 AM
  4. Calculate differences between age
    By carlharris in forum Excel General
    Replies: 1
    Last Post: 10-03-2005, 12:05 PM
  5. Forumla to calculate a percentage
    By julie regan in forum Excel General
    Replies: 1
    Last Post: 01-20-2005, 05:06 PM

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