Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TIME calculations...

Status
Not open for further replies.

ringd

Programmer
Jul 11, 2000
35
GB
Hello!

Does anybody know any clever ways of (for example) working out the difference, in seconds, of 2 time values (in normal format HH:MM:SS)?

Or have I got to manually write all the math code to do this?

Cheers,
Dave.
 
If I were you I would take a look at the TIME command.

There is a TIME('E') flavor of the command that will return the elapsed time since a timer was started or reset. If you want to know how long an EXEC ran for this is probably the easiest way of doing it.

Happy New Year
 
Unfortunately, yes. The up-side of that is that once written, you need never write it again :-S

If you had been asking about DATE(), the answer would have been different.
 
The best approach is calculate the number of seconds since some date in history -- 1900-01-01 usually works; then nbr of seconds since

is number of whole days*nbr of seconds per day PLUS seconds in current day

and calculate for both and subtract.

N E ????

bobh
 
number of seconds is the best way. I create a rexx function some time ago to do math calculations on time using number of seconds. convert both times to seconds the substract and get the diffence. I have a function if you are interest that works like the DATE() functions but for time conversions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top