Simply take the duration in seconds and divide by the number of seconds in a day to get the number of days. Take the remainder, divide by seconds in a hour to get the number of hours. Take the remainder, divide by seconds in a minute to get the number of minutes. Take the remainder and you have the number of seconds.
To me this is not much coding and is easy, for someone who has to pick up your code later, for others to follow.
You could play a “trick” in that if you know <b>with absolute certainty, and for all of time,</b> that the duration is always less than 24 hours then you add the duration to a time field initialized to 00.00.00, but this is really playing games — something to be avoided as it’s sure to mislead someone in the future. Less code for you now is not a good trade off for lots of debug time in the future…
Integrated solutions for the System i user community
Try this VBScript code for some ideas, basically it returns the number of seconds between the two <i>time stamps</i>.
Start = GetTime()
‘ your code here
‘end your code
WScript.Echo “Your code took ” & GetTimeDifference(Start) & ” seconds to complete.”
GetTime = Now()
GetTimeDifference = (Now() – Start)*1000 ‘return the number of seconds