【问题标题】:How do I format a Google Sheets duration formatted cell to show days, hours and minutes in a human readable format?如何格式化 Google 表格持续时间格式的单元格以以人类可读的格式显示天数、小时数和分钟数?
【发布时间】:2020-10-24 20:55:03
【问题描述】:

我在 Google 表格中的单元格当前显示两个日期时间之间的时间差,该单元格被格式化为持续时间,并显示为以小时、分钟和秒为单位的冒号分隔值。

以下示例。

788:42:07

如何格式化单元格以使其更易于阅读,特别是在显示持续时间的天、小时和分钟的格式中,并适当标记每个数值?

【问题讨论】:

    标签: google-sheets time google-sheets-formula datetime-format duration


    【解决方案1】:

    我发现有效的解决方案是编写一个公式,将现有的持续时间值转换为天、小时和分钟的各个持续时间组件值,然后将这些值与适当标记值的字符串连接起来。

    公式如下:

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

    其中 B4 是包含值的持续时间格式化单元格

    788:42:07

    包含解决方案公式的单元格现在显示持续时间单元格信息,如下所示:

    32 days 20 hours 42 minutes


    我发现以下资源有助于发现此问题的解决方案。

    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

    【讨论】:

      【解决方案2】:

      尝试:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-09-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多