Count days date range within 12 date ranges

strooman

Active Member
Joined
Oct 29, 2013
Messages
329
Office Version
  1. 2016
Platform
  1. Windows
How many days of a given date range in C2:D2, fall within multiple date ranges in columns A2:B13?
I'm interested in formulas in column E2:E13 (count per period) and F2 (total count). I typed in the desired results in Green.

Help is much appreciated.

ABCDEF
1Start_Of_MonthEnd_Of_MonthStartEndCountTotal_Count
21-1-201431-1-201415-3-201427-7-20140133
31-2-201428-2-20140
41-3-201431-3-201416
51-4-201430-4-201430
61-5-201431-5-201431
71-6-201430-6-201430
81-7-201431-7-201426
91-8-201431-8-20140
101-9-201430-9-20140
111-10-201431-10-20140
121-11-201430-11-20140
131-12-201431-12-20140

<tbody>
</tbody>
 
I don't understand your numbers sorry. There are 3 hours between 20:00 and 22:00 (20:00, 21:00 and 22:00). Perhaps you meant to start at 22:01.


From 20:00 to 22:00 = from 20:00 to 21:00 AND from 21:00 to 22:00. That makes 2 to me.
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
In that case why were there 30 days between 1 June and 30 June in your original post?

I understand and agree with your logical and unambiguously approach of the given problem. Unfortunately my supervisor wants it to calculate it that way. I tried to convince him that calculations for dates should be consistent with the calculations of the hours but that turned out to be a pointless effort.

So the calculations of hours should be slightly different then the dates but I think it can be down with the same formulas (with adjustments). I'm sorry for the confusion. Let me give a very straight example:
When a person works from 18:00 till 23:00 and he/she gets paid a special rate (122%) from 20:00 - 22:00 and a special rate(144%) from 22:00 - 23:00 then he gets that rate respectively for 2 hours and 1 hour. Hope this clarifies things and your help is much appreciated.
 
Upvote 0
OK try:


Excel 2010
ABCDEF
1Start_TimeEnd_TimeStartEndCountTotal_Count
200:0006:0005:0023:0015
306:0007:001
420:0022:002
522:0024:001
Sheet1
Cell Formulas
RangeFormula
E2=SUMPRODUCT(COUNTIFS(A2,"<"&(ROW(INDIRECT((C$2*24)+1&":"&(D$2*24)))/24),B2,">="&(ROW(INDIRECT((C$2*24)+1&":"&(D$2*24)))/24)))
F2=SUMPRODUCT(COUNTIFS(A2:A5,"<"&(ROW(INDIRECT((C$2*24)+1&":"&(D$2*24)))/24),B2:B5,">="&(ROW(INDIRECT((C$2*24)+1&":"&(D$2*24)))/24)))
 
Upvote 0
I'm not sure I have a full understanding of the requirement, but I'll jump back in with another try.
Is this close? If not, some more examples and expected results might help clarify.

Formula in E2, copied down.

Excel Workbook
ABCDEF
1Start_TimeEnd_TimeStartEndCountTotal_Count
20:006:005:0023:0015
36:007:001
420:0022:002
522:0024:00:001
Count Times
 
Last edited:
Upvote 0
Gentlemen, you both deserve a very big compliment. Not only for bringing in the right solution but even more for staying with me. I realize that my explanations were not always clear or unambiguously but during this process you kept looking for solutions. I really appreciate that. Men like you make this forum rock and very valuable.
This thread can go in the books as SOLVED. Thanks Peter and Andrew.
 
Upvote 0
Glad you got what you wanted. :)

Assuming my formula for column E in post #25 is producing what you want, then an adaptation of that should (I think) provide a simpler solution for that column of the earlier 'Dates' problem, even if the dates in columns A:B are not sequential, as follows.

Excel Workbook
ABCDE
1Start_Of_MonthEnd_Of_MonthStartEndCount
21/01/1431/01/1415/03/1427/07/140
31/02/1428/02/14.0
41/03/1431/03/1416
51/04/1430/04/1430
61/05/1431/05/1431
71/06/1420/06/1420
81/07/1431/07/1426
91/08/1431/08/140
101/09/1430/09/140
111/10/1431/10/140
121/11/1430/11/140
131/12/1431/12/140
Count Dates
 
Upvote 0

Forum statistics

Threads
1,215,123
Messages
6,123,183
Members
449,090
Latest member
bes000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top