如何在 Google 电子表格中进行时间/小时算术?

发布于 2024-12-27 04:19:13 字数 200 浏览 4 评论 0原文

如何在 Google 电子表格中进行时间/小时算术?

我有一个时间值(例如 36:00:00),我想将其除以另一个时间(例如 3:00:00)并得到 12。如果我只用一个时间除以另一个时间,我会得到 288 :00:00 当我想要的是 12 (或 12:00:00)时。

请注意,使用 hours() 函数不起作用,因为 36:00:00 会变成 12。

How do I do time/hour arithmetic in a Google spreadsheet?

I have a value that is time (e.g., 36:00:00) and I want to divide it by another time (e.g., 3:00:00) and get 12. If I divide just one by the other, I get 288:00:00 when what I want is 12 (or 12:00:00).

Note that using the hours() function doesn't work, because 36:00:00 becomes 12.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

任性一次 2025-01-03 04:19:13

当公式返回的数字被格式化为时间,并且您希望将其格式化为纯数字时,请将单元格的格式更改为纯数字格式:单击单元格,然后单击格式数字正常

Google 电子表格中的时间值以天和部分天表示。例如,36:00:00 是数字 1.5(一天半)的格式化表示。

假设您将 36:00:00 除以 3:00:00,如您的示例所示。 Google 电子表格执行计算 1.5 除以 0.125,即 12。结果告诉您,在 36 小时的时间段内有 12 个 3 小时的间隔。 12当然不是一个时间间隔。它是一个无单位的量。

另一方面,可以将任何数字格式化为时间。如果将 12 设置为时间格式,则可以合理地预期您将得到 288:00:00。 12天包含288小时。

When the number being returned by your formula is being formatted as a time, and you want it formatted as a plain number, change the format of the cell to a plain number format: click the cell and then click Format, Number, Normal.

Time values in Google spreadsheet are represented as days and parts of days. For example, 36:00:00 is the formatted representation of the number 1.5 (a day and a half).

Suppose you divide 36:00:00 by 3:00:00, as in your example. Google Spreadsheet performs the calculation 1.5 divided by 0.125, which is 12. The result tells you that you have 12 3-hour intervals in a 36-hour time period. 12, of course, is not a time interval. It is a unitless quantity.

Going the other way, it is possible to format any number as a time. If you format 12 as a time, it's reasonable to expect that you will get 288:00:00. 12 days contain 288 hours.

深居我梦 2025-01-03 04:19:13

Google 表格现在有一个持续时间格式选项。选择:格式->数量->期间。

Google Sheets now have a duration formatting option. Select: Format -> Number -> Duration.

淡忘如思 2025-01-03 04:19:13

计算时间的示例:

work-start   work-stop   lunchbreak    effective time

  07:30:00    17:00:00          1.5                 8  [=((A2-A1)*24)-A3]

如果将一个时间值减去另一个时间值,得到的结果将表示 24 小时的小数部分,因此,如果将结果乘以 24,则会得到以小时表示的值。

换句话说:操作是乘法,但含义是改变数字的格式(从天到小时)。

Example of calculating time:

work-start   work-stop   lunchbreak    effective time

  07:30:00    17:00:00          1.5                 8  [=((A2-A1)*24)-A3]

If you subtract one time value from another the result you get will represent the fraction of 24 hours, so if you multiply the result with 24 you get the value represented in hours.

In other words: the operation is mutiply, but the meaning is to change the format of the number (from days to hours).

幸福丶如此 2025-01-03 04:19:13

您可以使用谷歌电子表格的函数TIME(h,m,s)。如果要相互添加时间(或其他算术运算),可以为公式的每个输入指定一个单元格或对 TIME 的调用。

例如:

  • B3 = 10:45
  • C3 = 20(分钟)
  • D3 = 15(分钟)
  • E3 = 8(小时)
  • F3 = B3+时间(E3,C3+D3,0) 等于 19:20

You can use the function TIME(h,m,s) of google spreadsheet. If you want to add times to each other (or other arithmetic operations), you can specify either a cell, or a call to TIME, for each input of the formula.

For example:

  • B3 = 10:45
  • C3 = 20 (minutes)
  • D3 = 15 (minutes)
  • E3 = 8 (hours)
  • F3 = B3+time(E3,C3+D3,0) equals 19:20
北城半夏 2025-01-03 04:19:13

我使用了 TO_PURE_NUMBER() 函数并且它起作用了。

I used the TO_PURE_NUMBER() function and it worked.

爱,才寂寞 2025-01-03 04:19:13

我遇到了类似的问题,我现在只是修复了它,

  1. 将每个单元格格式化为时间
  2. 将总单元格(所有时间的总和)格式化为持续时间

I had a similar issue and i just fixed it for now

  1. format each of the cell to time
  2. format the total cell (sum of all the time) to Duration
我早已燃尽 2025-01-03 04:19:13

简单得多:看看这个

B2: 23:00
C2:  1:37
D2: = C2 - B2 + ( B2 > C2 )

为什么有效,时间是一天的一小部分,比较 B2>C2
如果添加 1 天(24 小时),则返回 True (1) 或 False (0)。
http://www.excelforum.com/ excel-general/471757-calculate-time-difference-over-midnight.html

So much simpler: look at this

B2: 23:00
C2:  1:37
D2: = C2 - B2 + ( B2 > C2 )

Why it works, time is a fraction of a day, the comparison B2>C2
returns True (1) or False (0), if true 1 day (24 hours) is added.
http://www.excelforum.com/excel-general/471757-calculating-time-difference-over-midnight.html

我恋#小黄人 2025-01-03 04:19:13

如果持续时间的单位为 h:mm,则存储在该单元格中的实际值是转换为实数的时间除以每天 24 小时。

例如:6:45 或 6 小时 45 分钟是 6.75 小时 6.75 小时 / 24 = 0.28125 (换句话说,6 小时 45 分钟是一天的 28.125%)。如果您使用列将持续时间转换为实际数字(例如,将 6:45 转换为 0.28125),那么您可以进行乘法或除法并得到正确的答案。

if you have duration in h:mm, the actual value stored in that cell is the time converted to a real number, divided by 24 hours per day.

ex: 6:45 or 6 hours 45 minutes is 6.75 hours 6.75 hours / 24 = 0.28125 (in other words 6hrs45minutes is 28.125% of a day). If you use a column to convert your durations into actual numbers (in example, converting 6:45 into 0.28125) then you can do you multiplication or division and get the correct answer.

甜味超标? 2025-01-03 04:19:13

如果您想在公式中对其进行格式化(例如,如果您要连接字符串和值),则上述 Google 格式选项不可用,但您可以使用 TEXT 公式:

=TEXT(B1-C1,"HH:MM:SS")

因此,对于有问题的示例,使用连接:

="The number of " & TEXT(B1,"HH") & " hour slots in " & TEXT(C1,"HH") _
& " is " & TEXT(C1/B1,"HH")

干杯

In the case you want to format it within a formula (for example, if you are concatenating strings and values), the aforementioned format option of Google is not available, but you can use the TEXT formula:

=TEXT(B1-C1,"HH:MM:SS")

Therefore, for the questioned example, with concatenation:

="The number of " & TEXT(B1,"HH") & " hour slots in " & TEXT(C1,"HH") _
& " is " & TEXT(C1/B1,"HH")

Cheers

南街女流氓 2025-01-03 04:19:13

在新的电子表格中,在 A1 中输入 36:00:00,在 B1 中输入 3:00:00,然后:

=A1/B1

假设在 C1 中返回 12

In an fresh spreadsheet with 36:00:00 entered in A1 and 3:00:00 entered in B1 then:

=A1/B1

say in C1 returns 12.

ぃ弥猫深巷。 2025-01-03 04:19:13

在单个单元格中输入值,因为谷歌电子表格根本无法处理任何形状或形式的持续时间格式。或者你必须学习制作剧本并毕业成为一名直升机飞行员。这也是一个选择。

Type the values in single cells, because google spreadsheet cant handle duration formats at all, in any way shape or form. Or you have to learn to make scripts and graduate as a chopper pilot. that is also a option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文