+ Reply to Thread
Results 1 to 6 of 6

Count days per month between two dates

  1. #1
    Registered User
    Join Date
    01-24-2013
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    5

    Count days per month between two dates

    Hey,

    There may already by a similar thread but I have not found it. I am currently trying to develop a formula to calculate the number of days per motnh between a range of dates. ie. Between December 30th and January 5th, how many days were in December and how many in January? So the response should be 2 and 5 respectively.

    I have modified a formula I found that has almost gotten the right output but the DAYS360 does not allow for the proper output as it seems to take a day off each month. Can someone help me rework this formula o maybe create a completely different one?? Here is the formula I am currently using and a copy of the sheet.

    =IF($B5="","",MAX(0,DAYS360(MAX($B5,D$3),MIN($C5,EOMONTH(D$3,0)))))
    Attached Files Attached Files

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

    Re: Count days per month between two dates

    I havnt looked at your file, but assuming date1 is in A1 and date2 is in B1, in C1 use this...
    =DATEDIF(A1,B1,"d")
    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
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Count days per month between two dates

    You can get the number of days between 2 dates with a simple subtraction of the earlier date from the later one, try this formula in D5 copied across and down

    =IF($B5="","",MAX(0,MIN($C5,D$4)-MAX($B5,D$3)+1))
    Audere est facere

  4. #4
    Registered User
    Join Date
    01-24-2013
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Count days per month between two dates

    That would work fine for just the numbers of days in between the dates in A1 and B1 but I need to know how many of those days are in January in C1, how many in February in D1, etc.

  5. #5
    Registered User
    Join Date
    01-24-2013
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Count days per month between two dates

    Thanks long legs. That seemed to be exactly what I needed!

  6. #6
    Registered User
    Join Date
    10-02-2012
    Location
    Baku
    MS-Off Ver
    Excel 2010
    Posts
    273

    Re: Count days per month between two dates

    An array formula

    d5 > =SUM(--((DATE(2013,D$1,ROW($1:$31))>=$B5)+(DATE(2013,D$1,ROW($1:$31))<=$C5)=2)) CSE

    added number of months to the first row as a helper column
    Attached Files Attached Files

+ 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