Count the number of days in a particular month

khaledhamdy

New Member
Joined
May 2, 2017
Messages
7
Hi guys,

how r u all.

Start Date End Date
4/30/2018 5/03/2018
5/1/2018 5/30/2018
4/28/2018 5/15/2018

as you can see I've two columns start date and end date and the values of each one of them.:)

what I need is to let the excel count the number of days that fall within a certain month for example April.

I already using this formula to count the days between every single start date and end date

=MAX(0,MIN(EOMONTH($A35,0),C$3)-MAX($A35,B$3)+1)

but I need to include the whole column of the start date and the whole column of the end date in this formula instead of repeat it for every single start date and end date.

I tried this but it didn't work: =MAX(0,MIN(EOMONTH($A35,0),$C$3:$C$28)-MAX($A35,$B$3:$B$28)+1)

I hope that my question is clear.

thanks in advance guys.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
try:


Book1
ABCDEFG
1Start DatEEND DATE
24/30/20185/3/2018days countstart1-Apr-18
35/1/20185/30/201834end30-Apr-18
44/28/20185/15/2018
53/2/20185/15/2018
65/8/20186/8/2018
Sheet1
Cell Formulas
RangeFormula
D3=SUMPRODUCT(SUBTOTAL(5,OFFSET(B2,ROW(A2:A6)-ROW(A2),0),G3)-SUBTOTAL(4,OFFSET(A2,ROW(A2:A6)-ROW(A2),0),G2)+1,(A2:A6<=G3)*(B2:B6>=G2))
 
Upvote 0
thank you :), it's working.

now because of the offset reference is not a range I can't fill it down to work in May & June, etc.... ;(

I've tried to replace the single cells to ranges but it didn't work

your valuable help, please.
 
Upvote 0
you can just set up your tab like this:


Book1
ABCDEFGHIJK
1Start DatEEND DATEApril 2018May 2018June 2018
24/30/20185/3/2018days countstart1-Apr-181-May-181-Jun-18
35/1/20185/30/201834Aprilend30-Apr-1831-May-1830-Jun-18
44/28/20185/15/201887May
53/2/20185/15/201830June
65/8/20187/8/2018
Sheet1
Cell Formulas
RangeFormula
H3=EOMONTH(H2,0)
I3=EOMONTH(I2,0)
J3=EOMONTH(J2,0)
D3=SUMPRODUCT(SUBTOTAL(5,OFFSET($B$2,ROW($A$2:$A$6)-ROW($A$2),0),INDEX(H$3:J$3,ROWS(D$3:D3)))-SUBTOTAL(4,OFFSET($A$2,ROW($A$2:$A$6)-ROW($A$2),0),INDEX(H$2:J$2,ROWS(D$3:D3)))+1,($A$2:$A$6<=INDEX(H$3:J$3,ROWS(D$3:D3)))*($B$2:$B$6>=INDEX(H$2:J$2,ROWS(D$3:D3))))
D4=SUMPRODUCT(SUBTOTAL(5,OFFSET($B$2,ROW($A$2:$A$6)-ROW($A$2),0),INDEX(H$3:J$3,ROWS(D$3:D4)))-SUBTOTAL(4,OFFSET($A$2,ROW($A$2:$A$6)-ROW($A$2),0),INDEX(H$2:J$2,ROWS(D$3:D4)))+1,($A$2:$A$6<=INDEX(H$3:J$3,ROWS(D$3:D4)))*($B$2:$B$6>=INDEX(H$2:J$2,ROWS(D$3:D4))))
D5=SUMPRODUCT(SUBTOTAL(5,OFFSET($B$2,ROW($A$2:$A$6)-ROW($A$2),0),INDEX(H$3:J$3,ROWS(D$3:D5)))-SUBTOTAL(4,OFFSET($A$2,ROW($A$2:$A$6)-ROW($A$2),0),INDEX(H$2:J$2,ROWS(D$3:D5)))+1,($A$2:$A$6<=INDEX(H$3:J$3,ROWS(D$3:D5)))*($B$2:$B$6>=INDEX(H$2:J$2,ROWS(D$3:D5))))
 
Last edited:
Upvote 0
thank you bro for your valuable support, the above formula has worked fine but it was too complicated, I tried to work the first one which you've provided and I changed only G3 & G2 to different cells based on each month start and end, and it worked fine.

again thanks a lot for the great support.
 
Upvote 0

Forum statistics

Threads
1,214,424
Messages
6,119,400
Members
448,893
Latest member
AtariBaby

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