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?
 
Happy you found a solution. Just a caution about using INDIRECT and TODAY. These are volatile functions and if you have really big workbook they will slow your workbook down. For 20 ROWS this should not be a problem.

the one thing I don't understand though is why are you using TODAY? Your values will change every day when you open the workbook. Is that what you want?
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
It was something I found online and seemed to work...no other reason. This is for an AirBnb, so I'll have more than 20 rows for sure. When I tried your formula, I got the Value error. Here is what I have:

=IF(MONTH($A27)=MONTH(P$5),
IF(MONTH(P$5)=MONTH($B27),$B27-$A27+1,EOMONTH($A27,0)-$A27+1),
IF(MONTH(P$5)=MONTH($B27),$B27-P$5+1,""))

A and B are in my/out dates....P is my month
 
Upvote 0
Wait...got yours working by changing my Aug to 8/31/23....but now September shows negative days (8/29-9/2 in my example)
 
Upvote 0
Wait...got yours working by changing my Aug to 8/31/23....but now September shows negative days.
Yes, I used actual date values in the month header column formatted as mmm-yy. And then use the MONTH function to get the month for the formulas. You seem to use a TEXT value for month, which works fine, but you can't really do date comparisons easily unless you extract the month as text.
 
Upvote 0
Yes, I used actual date values in the month header column formatted as mmm-yy. And then use the MONTH function to get the month for the formulas. You seem to use a TEXT value for month, which works fine, but you can't really do date comparisons easily unless you extract the month as text.
Not sure if you saw my edits....got yours working, but if I span 2 months, the second month is negative.
 
Upvote 0
Not sure if you saw my edits....got yours working, but if I span 2 months, the second month is negative.
right, I put that warning in my first post. I thought you said you did not span 2 months, maybe I'm mistaken. But, that can be accounted for with additional IF statements.
 
Upvote 0
right, I put that warning in my first post. I thought you said you did not span 2 months, maybe I'm mistaken. But, that can be accounted for with additional IF statements.
Sorry, I missed that part. And yes, I'll regularly cross months....its for an AirBnB.
 
Upvote 0
OKay, try this:

Book1
ABCDEFGHIJKLMNO
1Check INCheck OUTJan-23Feb-23Mar-23Apr-23May-23Jun-23Jul-23Aug-23Sep-23Oct-23Nov-23Dec-23# Calendar Months
22023-01-312023-03-1212812         2
32023-07-192023-08-27      1327    1
42023-05-262023-06-28    628      1
52023-06-022023-06-23     22      0
62023-07-302023-09-05      2315   2
72023-10-152023-11-11         1711 1
82023-07-172023-08-17      1517    1
92023-09-022023-10-10        2910  1
102023-09-212023-10-27        1027  1
112023-07-252023-08-14      714    1
122023-06-162023-07-12     1512     1
132023-08-282023-09-21       421   1
142023-01-152023-02-171717          1
152023-04-202023-05-11   1111       1
162023-10-262023-11-21         621 1
172023-07-062023-07-30      25     0
182023-07-272023-08-16      516    1
192023-05-012023-05-21    21       0
202023-09-132023-10-08        188  1
212023-08-072023-09-11       2511   1
Sheet1
Cell Formulas
RangeFormula
C2:N21C2=IF(MONTH($A2)=MONTH(C$1), IF(MONTH(C$1)=MONTH($B2),$B2-$A2+1,EOMONTH($A2,0)-$A2+1), IF(MONTH(C$1)=MONTH($B2),$B2-C$1+1, IF(AND(MONTH(C$1)>MONTH($A2),MONTH(C$1)<MONTH($B2)),EOMONTH(C$1,0)-C$1+1,"")))
O2:O21O2=MONTH(B2)-MONTH(A2)
 
Upvote 0

Forum statistics

Threads
1,215,298
Messages
6,124,116
Members
449,142
Latest member
championbowler

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