2 Replies Latest reply on Mar 9, 2014 2:57 PM by PaulWebb_1

# Converting minutes to D:H:M

### Title

Converting minutes to D:H:M

### Post

I came up with the below and it works. Just wanted to see if there is a better/shorter way to write it and if there are any gotchas I might be missing. Thanks for looking. The goal is to convert minutes to D:H:M.

examples

72 minutes = 1:12

1827 minutes = 1:06:27

// DAYS SECTION //////////////////////////////////

Case (
Int ( ( SR::INITIAL_RESPONSE_MIN / 60 ) / 24 ) < 1 ; "" ;
Int ( ( SR::INITIAL_RESPONSE_MIN / 60 ) / 24 ) & GetAsText ( ":" ) )

//////////////////////////////////////////////////////

&

// HOURS SECTION //////////////////////////////////

Case (
Int ( ( ( ( SR::INITIAL_RESPONSE_MIN / 60 ) / 24 ) - Int ( ( SR::INITIAL_RESPONSE_MIN / 60 ) / 24 ) ) * 24 ) < 10 ; 0 ; "" ) &
Int ( ( ( ( SR::INITIAL_RESPONSE_MIN / 60 ) / 24 ) - Int ( ( SR::INITIAL_RESPONSE_MIN / 60 ) / 24 ) ) * 24 )

& ":" &

//////////////////////////////////////////////////////

// MINUTES SECTION //////////////////////////////////

Case (

Round ( ( ( ( SR::INITIAL_RESPONSE_MIN / 60 ) - Int ( ( SR::INITIAL_RESPONSE_MIN / 60 ) ) ) * 60 ) ; 1 )  < 10 ; "0" ; "" )  &
Round ( ( ( ( SR::INITIAL_RESPONSE_MIN / 60 ) - Int ( ( SR::INITIAL_RESPONSE_MIN / 60 ) ) ) * 60 ) ; 1 )

//////////////////////////////////////////////////////

• ###### 1. Re: Converting minutes to D:H:M
Title:  Convert seconds to hours and Minutes (not decimal hours
Convert seconds to hours and Minutes (not decimal hours)

Then you'd need to craft your own calculation to separate out the days.

There are 86400 seconds in a day, 3600 in an hour, 60 in a minute. Ts1 and Ts2 are your two time stamp fields.

Let ( [ I = Ts2 - Ts1 ;
D = Div ( I ; 86400 ) ;
H = Div ( Mod ( I ; 86400 ) ; 3600 ) ;
M = Round ( ( I - ( D * 86400 ) - ( H * 3600 ) ) / 60 ; 0 ) ]
D & " Days " & H & " hours " & M & " minutes"
)

• ###### 2. Re: Converting minutes to D:H:M

Thanks David but I am not using timestamp fields. I have one field that is minutes in number format.