Checks if @date1 is less than or equal to @date2, and swap the values if this is not the case.
the second date