如何在 Google 电子表格中将正持续时间转换为负持续时间
How to convert a positive duration into a negative in Google Spreadsheet
我必须在 Google 电子表格应用程序中处理时间和持续时间,并且我必须使用负持续时间进行计算。
问题:
--------------------------------------------------------
Begin | End | Duration | calculated in negative (for some reasons)
--------------------------------------------------------
08:00 | 14:00 | 06:00 | no
10:00 | 15:00 | 05:00 | yes
如果 'Begin' 和 'End' 列的格式为 "Time",则可以在持续时间列中轻松计算差异。但是,似乎不支持使用像(end-begin)*(-1)
这样的简单解决方案将持续时间值转换为负数。
第一个解决方案:
通过以下公式我实现了一个目标:
[duration = end - begin]
(HOUR(duration)*60) + MINUTE(duration))(-1)
我不得不将持续时间转换为分钟,乘以 -1 将数字转换为负数。但这会导致奇怪的行为:
--------------------------------------------------------
Begin | End | Duration | calculated in negative (for some reasons)
--------------------------------------------------------
08:00 | 14:00 | 06:00 | no
10:00 | 15:00 | -7200:00:00 | yes
所以我试着用24、60、3600来划分,但似乎都不合适。直到我使用了神奇的数字 1440。
这个数字是60的倍数,正好是24次
最终解决方案:
[duration = end - begin]
((HOUR(duration)*60) + MINUTE(duration))(-1))/1440
我的问题是:
- 有谁知道为什么要使用 1440 这个号码?
- 还有其他方法可以解决这个问题吗?
Google 工作表将日期和时间视为序列号(与 Excel 相同):
today()
是 42 458;
- 明天 =
today() + 1
= 42 459;
每天算一个。
时间是0到1之间的数字。所以1有24小时,1小时有60分钟。因此要获得持续时间
- 分:=24*60=1440;
- 秒 = 24 * 60 * 60 = 86 400;
我必须在 Google 电子表格应用程序中处理时间和持续时间,并且我必须使用负持续时间进行计算。
问题:
-------------------------------------------------------- Begin | End | Duration | calculated in negative (for some reasons) -------------------------------------------------------- 08:00 | 14:00 | 06:00 | no 10:00 | 15:00 | 05:00 | yes
如果 'Begin' 和 'End' 列的格式为 "Time",则可以在持续时间列中轻松计算差异。但是,似乎不支持使用像(end-begin)*(-1)
这样的简单解决方案将持续时间值转换为负数。
第一个解决方案:
通过以下公式我实现了一个目标:
[duration = end - begin] (HOUR(duration)*60) + MINUTE(duration))(-1)
我不得不将持续时间转换为分钟,乘以 -1 将数字转换为负数。但这会导致奇怪的行为:
-------------------------------------------------------- Begin | End | Duration | calculated in negative (for some reasons) -------------------------------------------------------- 08:00 | 14:00 | 06:00 | no 10:00 | 15:00 | -7200:00:00 | yes
所以我试着用24、60、3600来划分,但似乎都不合适。直到我使用了神奇的数字 1440。 这个数字是60的倍数,正好是24次
最终解决方案:
[duration = end - begin] ((HOUR(duration)*60) + MINUTE(duration))(-1))/1440
我的问题是:
- 有谁知道为什么要使用 1440 这个号码?
- 还有其他方法可以解决这个问题吗?
Google 工作表将日期和时间视为序列号(与 Excel 相同):
today()
是 42 458;- 明天 =
today() + 1
= 42 459;
每天算一个。
时间是0到1之间的数字。所以1有24小时,1小时有60分钟。因此要获得持续时间
- 分:=24*60=1440;
- 秒 = 24 * 60 * 60 = 86 400;