title: How to compare two dates and take one that is smaller? e.g MIN for DATE
body: <p>This question is for educational purposes only, as I have already solved this problem in a way I dislike...</p>
  
  <p>Sheet looks following and has rows for months, in each row there is a column for days that month and for current month</p>
  
  <p><a href="https://i.stack.imgur.com/6RDij.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6RDij.png" alt="enter image description here"></a></p>
  
  <p>I have a formula that calculates how many days have passed this month or month that has passed which is used in some later calculations. </p>
  
  <pre><code>=TODAY()-DATE(2017,6,1)+1
  </code></pre>
  
  <p>Currently at the end of month I have to go and change formula to (as they go over 31 day in a month)</p>
  
  <pre><code>=DATE(2017,5,31)-DATE(2017,5,1)+1
  </code></pre>
  
  <p>What I would like to do is something like:</p>
  
  <p><code>=MIN(TODAY(),DATE(2017,6,30))-DATE(2017,6,1)+1</code> to take whichever date is less, so I could do the formulas for the months in advance and not need to go back to it at the end of every month...</p>
  
  <p>I can do it like <code>=MIN(TODAY()-DATE(2017,6,1),DATE(2017,6,30)-DATE(2017,6,1))+1</code> but it looks somewhat not nice...</p>
  
  <p><strong>How do I compare two dates and take one that is smaller?</strong></p>