poslaw Posted November 25, 2006 Posted November 25, 2006 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!
LaRetta Posted November 25, 2006 Posted November 25, 2006 (edited) 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 November 25, 2006 by Guest Corrected Calc - thank you Michael! :^)
LaRetta Posted November 25, 2006 Posted November 25, 2006 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. LaRetta
Recommended Posts
This topic is 6634 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 accountSign in
Already have an account? Sign in here.
Sign In Now