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!
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Dave Patton

Well-known Member
Joined
Feb 15, 2002
Messages
4,628
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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))
 

jg33

New Member
Joined
Apr 6, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
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?
 

jg33

New Member
Joined
Apr 6, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
ah i see what i did wrong by getting jan-00. However, now it stills says 31. Just like before...
 

Dave Patton

Well-known Member
Joined
Feb 15, 2002
Messages
4,628
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,127,405
Messages
5,624,574
Members
416,036
Latest member
eloisa manzanarez

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
Top