+ Reply to Thread
Results 1 to 10 of 10

Overlapping Date ranges

  1. #1
    Registered User
    Join Date
    01-01-2015
    Location
    sydney
    MS-Off Ver
    2010
    Posts
    5

    Overlapping Date ranges

    Forgive me but I have hijacked someone else question from another forum

    It defines what I'd like to do

    It works in the main exception pt ii & v

    The attached Excel sheet should be self-explanatory I hope!

    I have a fixed date range, "F" (A3:B3) and a number of variable date ranges ("V") in columns D and E.

    I want column F to return the number of days between D and E that fall within range F All 6 possible examples are listed-

    (i) V starts and ends before F = 0 days
    (ii) V starts before range F and ends within F = some of F (start F - end V)
    (iii) V starts before before F and ends after F = all of F
    (iv) V starts within F and ends within F = some of F (end V - Start V)
    (v) V starts within F and ends after F = some of F (start V - end F +1)
    (vi) V starts after F and ends after F = 0 days


    I've tried 3 different scenarios, all came up with the same answer

    .=MAX(0,MIN(B$3,E3)-MAX(A$3,D3)+1)
    .=MAX(MIN($B$3,E3)-MAX(D3,$A$3)+1,0)
    .=IF(OR($B$3<D3,$A$3>E3),0,(MIN($B$3,E3)-MAX($A$3,D3)+1))

    (I think the latter is possibly my best bet but I'm unable to tweak it the correct way)

    All help greatly appreciated
    Attached Files Attached Files

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,058

    Re: Overlapping Date ranges

    Can you also manually write expected results?
    Never use Merged Cells in Excel

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Overlapping Date ranges

    Hi,

    What answers do you expect for items ii) and v) if not 20 & 27 in F4 & F7 respectively?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    01-01-2015
    Location
    sydney
    MS-Off Ver
    2010
    Posts
    5

    Re: Overlapping Date ranges

    Thanks Richard & zbor for the quick responses I've tweaked my sheet so to represent a clearer explanation of what im trying to achieve..

    The sheet represents a payment schedule, & in this case 31 days in the month

    If I use examples ii & v it gives me a total of 32 days

    In example ii I'm trying to achieve 4 days instead of 5 & in iv 25 instead of 26

    The tweaking is in ii & v as explained above

    I'v also manually input in col G what im expecting

    Hope this ia little clearer

    pvd

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Overlapping Date ranges

    Hi,

    This clearly revolves around whether dates are counted as inclusive or not. But can I check your logic

    i) counts the whole month of August - hence start and end dates are inclusive i.e. 31 days
    ii) this seems to ignore the requirement to count the 'last' day, i.e. 5th and you want an answer of 4
    iii) again this is a complete month as i) above hence 31 days
    iv) from 5 Aug to 30 Aug is 26 inclusive days yet you want to ignore one day and show 25
    v) from 5 Aug to 31 Aug is 27 inclusive days

    What is your rule for ignoring an inclusive day in ii) and iv) but not else where. If it's where the start or end date is within the month then maybe in F3 copied down try

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    but it doesn't seem entirely consistent

  6. #6
    Registered User
    Join Date
    01-01-2015
    Location
    sydney
    MS-Off Ver
    2010
    Posts
    5

    Re: Overlapping Date ranges

    Muchly appreciated Richard

    By way of explanation as i said its a series of payments schedules

    I'll use the example of 30/6/15 to 15/10/15
    Date diff is 107 days because you count the first day but not the last in the payment schedule. Schedule is on a monthly basis

    If it were to be split (because a change of rate)

    Jun=1
    Jul=31
    Aug=31
    Sep=30
    Oct=14 (15-1)
    And i have many to work thru , all with varying start/end date

    Because the all encompassing formula in excel usually requires +1 (& it works in a majority of instances, as demonstrated on the sheet) I needed a fix that made an allowance for a finish date in the month that didn't require the +1 & although I'm not a complete newbie I could get my head around solving this... You have & I'm very very grateful

    pvd

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Overlapping Date ranges

    Hi,

    Just has another thought and that's if both D3>A3 and E3>B3 two days will get added which may not be what you want. You may need a final If Test

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,745

    Re: Overlapping Date ranges

    Double Edited Changed formula ... again.

    Do you have many rows of data to calculate?

    See if this array formula does what you want.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlameRetired; 01-05-2016 at 11:09 PM.
    Dave

  9. #9
    Registered User
    Join Date
    01-01-2015
    Location
    sydney
    MS-Off Ver
    2010
    Posts
    5

    Re: Overlapping Date ranges

    Richard apologies for the delay. Tested at home & so far so good

    Appreciate the followup

  10. #10
    Registered User
    Join Date
    01-01-2015
    Location
    sydney
    MS-Off Ver
    2010
    Posts
    5

    Re: Overlapping Date ranges

    G'day Dave. Looks good but as I'm on an iPad I report back when in front of a desktop

    Thanks for the response!

+ 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. [SOLVED] Calculating # of Overlapping days with several date ranges and conditions
    By ZafferAhmed in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-30-2021, 05:44 AM
  2. Calculating # of Overlapping days with several date ranges.
    By CarlSVM in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 01-06-2014, 07:09 AM
  3. Summing # of overlapping days with lots of date ranges
    By tvnsf in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-08-2013, 01:48 PM
  4. Charting Amounts Between Overlapping Date Ranges
    By thomasutley in forum Excel General
    Replies: 0
    Last Post: 09-27-2011, 12:43 PM
  5. how to count # rows having overlapping date ranges
    By jrtaylor in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-13-2011, 01:54 PM
  6. Counting Continuous Days within overlapping Date Ranges
    By mgaworecki in forum Excel General
    Replies: 3
    Last Post: 09-07-2011, 08:33 AM
  7. preventing overlapping date ranges
    By xlfan in forum Excel General
    Replies: 2
    Last Post: 03-01-2011, 10:03 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