PhilD said:
Ah, if you format your cells as stated previously, then this should be
quite straightforward, as 12 hours just happens to be 0.5 days.
Suppose your data is in columns A to D, and the data in row 2. Cell D2
(where you want the 1.00 to appear) should contain
=C2-B2-0.5
That's it! You are stating "9 o'clock in the evening minus 8 o'clock
in the morning is 13 hours. Deduct half a day leaves 1 hour".
One thing worth noting:
If your times could span midnight, e.g.:
Date start finish Hours overtime
11-Sep 20:00 09:00 1.00
You'll need to adjust for the finish time being smaller to XL (e.g.,
0.375) than the start time (e.g., 0.8). One way to do this is to use
the fact that XL treats TRUE/FALSE in math formulas as 1/0:
=(C2 - B2 - 0.5 + (C2 < B2)) * 24
(Again, the * 24 is necessary to get your desired decimal hours).
A somewhat obscure alternative would be to use the MOD function:
=(MOD(C2 - B2, 1) - 0.5) * 24
or, equivalently, and perhaps making the intent more clear:
=MOD(C2 - B2, 1) * 24 - 12
Also note that, while XL will, when the cell display formats are set to
"h:mm", display 0.875 as 21:00, there's nothing inherently associated
with that value that determines that it's to be interpreted as 9 o'clock
in the evening. It's simply a value, so XL will happily take the square
root of 9:00 PM and return 10:27 PM (i.e., SQRT(0.875) = 0.935414347).