简体   繁体   中英

How do I format a Google Sheets duration formatted cell to show days, hours and minutes in a human readable format?

The cell I have in Google Sheets currently shows the difference in time between two date-times, the cell is formatted as a duration and displays as a colon separated value in hours, minutes and seconds.

Example below.

788:42:07

How do I format the cell to be more human readable, specifically in the format that shows the days, hours and minutes of the duration with each numeric value labelled appropriately?

The solution I found to be effective was writing a formula the converted the existing duration value into the individual duration component values of days, hours and minutes and then concatenates these values with strings that label the values appropriately.

The formula is as follows:

=int(B4)&" days "&hour(mod(B4,1))&" hours "&minute(mod(B4,1))&" minutes"

with B4 being the duration formatted cell containing the value

788:42:07

The cell containing the solution formula now displays the duration cell information as follows:

32 days 20 hours 42 minutes


I found the following resources useful in discovering the solution to this question.

https://infoinspired.com/google-docs/spreadsheet/convert-time-duration-to-day-hour-minute-in-google-sheets/

Google Sheets INT formula documentation

Google Sheets MOD formula documentation

Google Sheets HOUR formula documentation

Google Sheets TEXT formula documentation

try:

=QUOTIENT(TEXT(A1, "[hh]")/24, 1)&"d "&TEXT(MOD(VALUE(A1), 1), "hh:mm")

在此处输入图像描述

0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM