Q:

How to compare two dates and take one that is smaller? e.g MIN for DATE

This question is for educational purposes only, as I have already solved this problem in a way I dislike...
Sheet looks following and has rows for months, in each row there is a column for days that month and for current month

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. 
=TODAY()-DATE(2017,6,1)+1

Currently at the end of month I have to go and change formula to (as they go over 31 day in a month)
=DATE(2017,5,31)-DATE(2017,5,1)+1

What I would like to do is something like:
=MIN(TODAY(),DATE(2017,6,30))-DATE(2017,6,1)+1 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...
I can do it like =MIN(TODAY()-DATE(2017,6,1),DATE(2017,6,30)-DATE(2017,6,1))+1 but it looks somewhat not nice...
How do I compare two dates and take one that is smaller?

A:

After a chat room discussion, it appears that one problem was the formatting of the results.
So =MIN(TODAY(),DATE(2017,6,30))-DATE(2017,6,1)+1 is sufficient 
Excel stores dates as serial numbers with 1 = 1-Jan-1900.
If one wants to return a date, the cell containing the formula should be formatted as a date.
If one wants to return a numeric value, the cell containing the formula should be formatted as General or as a number with the appropriate number of decimals.
Excel does not always format the cell as desired by the user, so this may need to be edited.

