I have to deal with time and duration in Google Spreadsheet App and I have to calculate with negative duration.
Problem:
-------------------------------------------------------- Begin | End | Duration | calculated in negative (for some reasons) -------------------------------------------------------- 08:00 | 14:00 | 06:00 | no 10:00 | 15:00 | 05:00 | yes
If column 'Begin' and 'End' were formatted as "Time", the difference can be easily calculated in the duration column. However converting the duration value into a negative one with a simple solution like(end-begin)*(-1)
seems not to be supported.
First solution:
With the following formula I achieved one goal:
[duration = end - begin] (HOUR(duration)*60) + MINUTE(duration))(-1)
I had to convert the duration into minutes, multiply with -1 to convert the number into negative. But this leads to a strange behavior:
-------------------------------------------------------- Begin | End | Duration | calculated in negative (for some reasons) -------------------------------------------------------- 08:00 | 14:00 | 06:00 | no 10:00 | 15:00 | -7200:00:00 | yes
So I tried to divide it with 24, 60, 3600, but nothing seems to fit. Until I used the magic number 1440. This number is a multiple of 60, exactly 24 times.
Final solution:
[duration = end - begin] ((HOUR(duration)*60) + MINUTE(duration))(-1))/1440
My questions are:
- Does anyone know why to use the number 1440?
- Is there another way to solve this problem?