Count days per month within interval

jg33

New Member
Joined
Apr 6, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello!

I'm wondering how I count numbers of days per month month within a dateinterval?

Here is an exempel of how I want it.

A B C D E F

1. Start date End date Jan Feb Mar Apr

2. 01-15-2019 04-08-2019 17 28 31 8

I have the start date and the end date to begin with. And also in cell C1 it says 01-01-2019 and not just Jan and so on for the rest of the months.

I have tried this formula: =MAX(0,(MIN($A2,DATE(YEAR(C$1),MONTH(C$1)+1,0))-MAX($B2,C$1)+1))

However, for January I get the number 31 instead of 17.

Anyone have a solution?

Thanks!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
T202004a.xlsm
ABCDEFGH
1StartEndTotalJan-19Feb-19Mar-19Apr-19May-19
215-Jan-1908-Apr-198417283180
3
2a
Cell Formulas
RangeFormula
C2C2=B2-A2+1
D2:H2D2=MAX(0, MIN(EOMONTH(D$1, 0), $B2) + 1 - MAX(D$1, $A2))
 
Upvote 0
Hi! Thanks for trying to help! However, now instead of getting the number 31 för january it just says "jan-00".
Also, what is the purpose of calculating C2?
 
Upvote 0
ah i see what i did wrong by getting jan-00. However, now it stills says 31. Just like before...
 
Upvote 0
try copying the suggestion onto a new sheet
review the formula; you can use Excel's formula evaluate if you want
ensure you format only the dates as dates
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,214
Members
448,874
Latest member
b1step2far

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