title: Excel - count days in specific month between two dates
body: <p>I have a home rental business, I wish to calculate the occupancy rate.
  For that, I need to calculate the number of nights in a specific month between 2 dates (check-in and check-out).</p>
  
  <p>Here's an example:</p>
  
  <pre><code>          A          B          C         D         E        F 
  
  1  |     IN     |   OUT    |  NIGHTS | 01/01/18 | 01/02/18 |...
     ------------------------------------------------------------
  2  |  15/01/18  | 25/01/18 |   10    |  10      |  0       |...
     ------------------------------------------------------------
  3  |  28/01/18  | 04/02/18 |   7     |  3       |  3       |...
  </code></pre>
  
  <p>Here are the formulas for:</p>
  
  <p><code>C3 = B3-A3</code></p>
  
  <p><code>D3 =  MAX(0; MIN(EOMONTH(D$1;0); $B3) - MAX(D$1; $A3))</code></p>
  
  <p>I think I'm not too far but the formula is still incorrect.
  As you can see, D2 is correct, but D3 is wrong.
  This is the tricky part, when the stays overlaps on 2 months, Jan and Feb in thisi case.
  D3 should show 4 nights and not 3.</p>
  
  <p>Anyone can help please? Thanks in advance!</p>
  
  <p>PS: sorry for the formatting but I am not able to add a screenshot..</p>