Converts a time duration in minutes to a readable format (e.g., 1 hr 30 min)
=IF(base_unit = "days",
IF(INT(duration/365) > 0, INT(duration/365) & " yr ", "") &
IF(INT(MOD(duration, 365)/30.44) > 0, INT(MOD(duration, 365)/30.44) & " mo ", "") &
IF(ROUND(MOD(duration, 30.44), 0) > 0, ROUND(MOD(duration, 30.44), 0) & " d ", ""),
IF(base_unit = "hours",
IF(INT(duration/8760) > 0, INT(duration/8760) & " yr ", "") &
IF(INT(MOD(duration, 8760)/730) > 0, INT(MOD(duration, 8760)/730) & " mo ", "") &
IF(INT(MOD(duration, 730)/24) > 0, INT(MOD(duration, 730)/24) & " d ", "") &
IF(MOD(duration, 24) > 0, MOD(duration, 24) & " hr ", ""),
IF(base_unit = "minutes",
IF(INT(duration/525600) > 0, INT(duration/525600) & " yr ", "") &
IF(INT(MOD(duration, 525600)/43800) > 0, INT(MOD(duration, 525600)/43800) & " mo ", "") &
IF(INT(MOD(duration, 43800)/1440) > 0, INT(MOD(duration, 43800)/1440) & " d ", "") &
IF(INT(MOD(duration, 1440)/60) > 0, INT(MOD(duration, 1440)/60) & " hr ", "") &
IF(MOD(duration, 60) > 0, MOD(duration, 60) & " min ", ""),
IF(base_unit = "seconds",
IF(INT(duration/31536000) > 0, INT(duration/31536000) & " yr ", "") &
IF(INT(MOD(duration, 31536000)/2628000) > 0, INT(MOD(duration, 31536000)/2628000) & " mo ", "") &
IF(INT(MOD(duration, 2628000)/86400) > 0, INT(MOD(duration, 2628000)/86400) & " d ", "") &
IF(INT(MOD(duration, 86400)/3600) > 0, INT(MOD(duration, 86400)/3600) & " hr ", "") &
IF(INT(MOD(duration, 3600)/60) > 0, INT(MOD(duration, 3600)/60) & " min ", "") &
IF(MOD(duration, 60) > 0, MOD(duration, 60) & " sec", "")
))))
This function provides a granular breakdown of time for activities or projects. This detailed time format is especially useful in environments like project management, long-term planning, and reporting, where understanding the duration across different scales is essential. The inputs need to be in minutes. For example, if A1
contains 2,000,000
minutes
, the function =DURATION_FORMAT(A1)
would output something like 3 yr 9 mo 20 d 21 hr 20 min
, offering a comprehensive view of the time duration. This enables precise and understandable time statements that can help in evaluating time durations.
Function name: DURATION_FORMAT
Function description: Converts a time duration in minutes to a readable format (e.g., 1 hr 30 min)
Argument placeholders: duration, base_unit
Formula definition: =IF(base_unit = "days", IF(INT(duration/365) > 0, INT(duration/365) & " yr ", "") & IF(INT(MOD(duration, 365)/30.44) > 0, INT(MOD(duration, 365)/30.44) & " mo ", "") & IF(ROUND(MOD(duration, 30.44), 0) > 0, ROUND(MOD(duration, 30.44), 0) & " d ", ""), IF(base_unit = "hours", IF(INT(duration/8760) > 0, INT(duration/8760) & " yr ", "") & IF(INT(MOD(duration, 8760)/730) > 0, INT(MOD(duration, 8760)/730) & " mo ", "") & IF(INT(MOD(duration, 730)/24) > 0, INT(MOD(duration, 730)/24) & " d ", "") & IF(MOD(duration, 24) > 0, MOD(duration, 24) & " hr ", ""), IF(base_unit = "minutes", IF(INT(duration/525600) > 0, INT(duration/525600) & " yr ", "") & IF(INT(MOD(duration, 525600)/43800) > 0, INT(MOD(duration, 525600)/43800) & " mo ", "") & IF(INT(MOD(duration, 43800)/1440) > 0, INT(MOD(duration, 43800)/1440) & " d ", "") & IF(INT(MOD(duration, 1440)/60) > 0, INT(MOD(duration, 1440)/60) & " hr ", "") & IF(MOD(duration, 60) > 0, MOD(duration, 60) & " min ", ""), IF(base_unit = "seconds", IF(INT(duration/31536000) > 0, INT(duration/31536000) & " yr ", "") & IF(INT(MOD(duration, 31536000)/2628000) > 0, INT(MOD(duration, 31536000)/2628000) & " mo ", "") & IF(INT(MOD(duration, 2628000)/86400) > 0, INT(MOD(duration, 2628000)/86400) & " d ", "") & IF(INT(MOD(duration, 86400)/3600) > 0, INT(MOD(duration, 86400)/3600) & " hr ", "") & IF(INT(MOD(duration, 3600)/60) > 0, INT(MOD(duration, 3600)/60) & " min ", "") & IF(MOD(duration, 60) > 0, MOD(duration, 60) & " sec", "") ))))
Argument description (duration): The total duration according to the selected base unit
Argument example (duration): 90
Argument description (base_unit): What the base units of the duration are. Either "seconds", "minutes", "hours", or "days" to define the base unit of the input duration
Argument example (base_unit): "minutes"
Named functions enable the creation of custom, reusable formulas that mimic built-in functions, streamlining calculations and data manipulations. These functions simplify complex formulas, making spreadsheets more readable and less prone to errors. By encapsulating intricate logic within a single function call, they enhance consistency across your data. Utilizing named functions reduces the need to write lengthy formulas repeatedly, thereby improving workflow efficiency and productivity in data analysis and management.
Follow these simple steps to download and import the function into your spreadsheet. This method is the quickest and easiest way to add the named function to your Google Sheets document, but will not include the argument description and examples:
Once added, the function will be ready to use in your document like any other built-in function. Simply type the function name and provide the required inputs to use it in your calculations.
Follow these simple steps to integrate the function into your spreadsheet:
Once added, the function will be ready to use in your document like any other built-in function. Simply type the function name and provide the required inputs to use it in your calculations.
Copyright © 2024 Keshia Rose. All rights reserved for website content. Individual functions are available under an MIT License.
This site is not associated with or endorsed by Google.