Calculating number of days from each month, from a range for a short term rental model

ORDub

New Member
Joined
Apr 10, 2013
Messages
16
Platform
  1. MacOS
The example is that I would have Column A as the date someone checks into a short term rental (lets say August 26), and Column B is the date the check out (lets say September 6). So in this, they stayed 5 nights in August, and 5 nights in September (they leave on the 6th)....if I have 20 rows of ranges like this, I need to be able to create a table that shows the nights stayed each month.

Thoughts?
 
Just figured it out...

=SUMPRODUCT(--(TEXT(ROW(INDIRECT($A6&":"&IF($B6="",TODAY(),$B6-1))),"mmm")=Q$5))
Could I suggest a small change to your layout and a non-volatile & slightly simpler formula?

Instead of text dates "Jan", "Feb" etc as you apparently have (& I have in Q5:AB5 below), use actual dates being the first day of each month and format those cells as "mmm" (as I have in C5:N5 below)
I have your formula in columns Q:AB and the simpler alternative in columns C:N and you will see they are producing identical results.

23 08 31.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
5Check INCheck OUTJanFebMarAprMayJunJulAugSepOctNovDecJanFebMarAprMayJunJulAugSepOctNovDec
631/01/2312831303130313100001283130313031310000
719/07/2327/08/230000001326000000000013260000
826/05/2328/06/2300006270000000000627000000
92/06/2323/06/2300000210000000000021000000
1030/07/2300000023100000000002310000
1115/10/2311/11/230000000001710000000000017100
1217/07/2317/08/230000001516000000000015160000
132/09/2310/10/2300000000299000000000029900
ORDub
Cell Formulas
RangeFormula
C6:N13C6=MAX(MIN(EOMONTH(C$5,0),IF($B6="",TODAY(),$B6-1))-MAX(C$5,$A6)+1,0)
Q6:AB13Q6=SUMPRODUCT(--(TEXT(ROW(INDIRECT($A6&":"&IF($B6="",TODAY(),$B6-1))),"mmm")=Q$5))
 
Last edited:
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
@Peter_SSs , Isn't TODAY() also a volatile function? Or is it volatile in only certain situations?
 
Upvote 0
@Peter_SSs , Isn't TODAY() also a volatile function? Or is it volatile in only certain situations?
Yes, you are absolutely correct, TODAY() is also volatile. I'm so used to focussing on INDIRECT and OFFSET. :oops:
Still, I think the formula is probably a better one and =TODAY() could be put in a single cell somewhere else & use that cell reference in the formula instead of the actual TODAY function.
 
Upvote 0

Forum statistics

Threads
1,215,308
Messages
6,124,178
Members
449,146
Latest member
el_gazar

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