Mark,
The second half of the formula, +(StartTime>EndTime), is used to
correct the value if the StartTime is before midnight and the
EndTime is after midnight; for example, if you start at 9PM and
end at 3AM.
Times are stored as a fraction of a 24 hour day, so 9PM is stored
as 0.875 and 3AM is stored as 0.125. If you simply subtract
EndTime - StartTime, you'll end up with 0.125 - 0.875, or -0.75.
This is remedied by the second part of the formula.
If StartTime is greater than EndTime (9PM is later than 3AM), the
comparison StartTime>EndTime returns TRUE which is treated as 1.
This adds 1, the equivalent of 24 hours, to the result, which
makes the example formula 0.125 - 0.875 + 1 = 0.25, or 6:00.
In effect, the +(StartTime>EndTime) moves the EndTime in to the
following day.
For lots more information about working with dates and times in
Excel, see
www.cpearson.com/excel/datetime.htm .
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com