When i try to sum all the total hours, including empty cells, i get this negative result. What am i doing wrong?
test.ods (11.5 KB)
When i try to sum all the total hours, including empty cells, i get this negative result. What am i doing wrong?
test.ods (11.5 KB)
HH:MM
is expected to suppress a date part possibly contained in the actual value of the cell.H
or HH
) to a maximum of 2 digits. Use [HH] instead to at least avoid unnoticed errors of the kind.04:00
behind a 22:00
is meant to mean “the day after”. Sheets don’t guess generally - and if they do they’re mostly wrong.3:30
(e.g.). The actual value of the cell would be 0.1458333...
for the example. To get the number of hours you need to multiply that result by 24 (assumed 1 d = 24 h – which is currently broken twice a year in many countries).No, he is using [HH]:MM actually. At least for the sum.
Yes, and only for the sum.
The intervals are always below 1, so the formatting makes no difference.
Set [HH] also for the differences per row, and the error will easily get noticed (negative “durations”).
When you remove the time formatting, you see that “times” are decial fractions, fractions of days.
0.25 → 06:00
0.5 → 12:00
0.75 → 18:00
06:00 - 18:00 actually calculates
0.25 - 0.75
You have to add one day in order to calculate the time difference from 18:00 until next day’s 6:00.
=C2-B2+(B2>C2) which adds 1 if B2>C2
You simply made a very common understanding error.
When you write something looking like a date or a time, Writer encodes this as a date-time floating-point value. The integral part of this value is the number of days since the epoch and the decimal part is the fraction of the day, where 0.0 is 00:00:00 up to 0.9999… for 23:59:59.999…
In your row 7, your starting hour is 20:00 and the ending hour 9:00, presumably on next day but encoding shows the date part is the same. Therefore, when you subtract you get a negative result which can be masked if you chose an incorrect formatting. [HH]:MM
is dedicated to full number of hours without being clipped to 0-23.
Computing a time span requires some precaution, notably checking for midnight crossing.
Hallo
change the Formula in D2 to =C2-B2+(C2<B2)
and pull down.