Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
753 views
in Technique[技术] by (71.8m points)

time - How to format a duration as HH:mm in the new Google sheets

In the new Google sheets there's a way of formatting a number as a duration. Format -> Number -> Duration.

  • 1 is formatted as 24:00:00
  • 1.2 is formatted as 28:48:00
  • 1.5 is formatted as 36:00:00
  • 0.03125 is formatted as 0:45:00.

I don't need the seconds in the duration representation, because they bloat my timesheet.

How can I format a duration as HH:mm (without using a formula to calculate hours and minutes and concatenate that with a colon). Is there a way of using the TEXT formula.

This is how I would like it:

  • 1 is formatted as 24:00
  • 1.2 is formatted as 28:48
  • 1.5 is formatted as 36:00 (I don't need 12:00 which datetime-formatting would accomplish)
  • 0.03125 is formatted as 0:45
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There is no need to use formulas for that, you can define your own custom formats.

Just go to Format -> Number -> More formats -> More date and time formats. It will open a window with several date and time formats to choose from. You can define your own as well, using the upper text area:

  1. Click on the small arrow on the left, and select the first element you want to add: elapsed hours. Notice there are two different "hours", one for time and another for durations.
  2. Type your separator text :
  3. Click on the arrow again and add the second element: Elapsed Minutes.
  4. Finally, click on each element you added, to determine the correct format (trailing zeros or not, for example).

Custom Date Format Screenshot


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...