Jump to content

Convert Hours Into Days


 Share

This topic is 5789 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have been wondering on where to start with this. Any help is appreciated.

I have a calculation that returns the time a record was last updated but it is in hours. How can I convert it to days:

My calculated result: 25:14:01

Desired result: 1 Day, 1 Hour, 14 Minutes

Thanks!

Link to comment
Share on other sites

There may be easier ways but this works:

Let ( [

d = Div ( theTime ; 86400 ) ;

t = Mod ( theTime ; 86400 ) ;

h = Hour ( t ) ;

m = Minute ( t ) ;

s = Seconds ( t )

] ;

If ( d ; d & " Day" & If ( d > 1 ; "s" ) ) &

If ( h ; ", " & h & " Hour" & If ( h > 1 ; "s" ) ) &

If ( m ; ", " & m & " Minute" & If ( m > 1 ; "s" ) ) &

If ( s ; ", " & s & " Second" & If ( s > 1 ; "s" ) )

)

UPDATE: Corrected calc on t line. I had t = Mod ( theTime ; d * 86400 ) which was redundant. All I needed was 86400. :)

Edited by Guest
Corrected Calc - thank you Michael! :^)
Link to comment
Share on other sites

I re-wrote the calc. If there was no days then it was producing the comma before the hours. This works no matter what:

Let ( [

d = Div ( theTime ; 86400 ) ;

t = Mod ( theTime ; 86400 ) ;

h = Hour ( t ) ;

m = Minute ( t ) ;

s = Seconds ( t )

] ;

If ( d ; d & " Day" & If ( d > 1 ; "s" ) & If ( h or m or s ; ", " ) ) &

If ( h ; h & " Hour" & If ( h > 1 ; "s" ) & If ( m or s ; ", " ) ) &

If ( m ; m & " Minute" & If ( m > 1 ; "s" ) & If ( s ; ", " ) ) &

If ( s ; s & " Second" & If ( s > 1 ; "s" ) )

)

I must remember to extend the same theory through an entire calc or it can bite me somewhere. :wink2:

LaRetta

Link to comment
Share on other sites

This topic is 5789 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.