Total Elapsed Time

Discussions about CSEntry
Post Reply
Nikola
Posts: 27
Joined: December 24th, 2021, 4:30 am

Total Elapsed Time

Post by Nikola »

How can I indicate the total time elapsed during the session in question?
I want to make a format like HH:MM (e.g. hours:minutes).

I tried using Timestamp Function.

1. PROC START_TIME
Preproc
$ = timestamp();

2. PROC END_TIME
Preproc
$ = timestamp();

3. PROC DURATIOIN
Prerpoc
$ = END_TIME - START_TIME;

However, it only shows in seconds (e.g. 70 minutes)

In addition, I tried to use TimeString Function. However, I didn't understand (especially the TimeString format) and how to apply it.

Thank you in advance.
Attachments
1222.png
1222.png (13.65 KiB) Viewed 722 times
Gregory Martin
Posts: 1793
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Total Elapsed Time

Post by Gregory Martin »

The timestring function is for formatting dates and or/times. It can't be used for formatting a duration. In your case, you can use some math to get the values you want:
numeric elapsed_seconds = END_TIME - START_TIME;

numeric hours = int(elapsed_seconds / 60 / 60);
numeric minutes = int(elapsed_seconds / 60) % 60;

errmsg("Duration is %02d:%02d", hours, minutes);
Post Reply