Sum of time duration


how can i add the sum of the duration in this situation? by adding a record to "listpicker". I can't find similar posts in the forum.

Hello,
As I mentioned in post below that duration return in milliseconds, what if you sum up all durations in a variable and finally, you will be having time in milliseconds, and now you know how convert to HH:MM or other desired format.

totalDuration = totalDuration + newDuration

2 Likes

You are not making things easier for yourself when you store your data in display format only.

Like handkerchiefs, you should have one for show and one for blow(internal use only).

Your internal use list can be a list of pairs (2 item sublists) with each item containing

  • Start Time (in ms format of Clock1.SystemTime) and
  • EndTime (also in ms format of Clock1.SystemTime).

Duration (ms) of each pair is gotten by subtracting item 1 (start time) from item 2 (end time).

Start with the list initially empty, and add a pair only when the End button is Clicked, taking the Start Time from the global variable that catches Clock1.SystemTime when the Start button is clicked, and the End time from Clock1.SystemTime.

Don't Enable the End button until the Start button has been clicked, to avoid taking a default Start time of 1970.

Any time you want a View of that list, run the pairs through a for each block into an empty list, formatting and JOINing the two items to taste for your ListView or List Picker Elements.
This should be a read-only operation. Don't mess up your hard earned list of pairs.

2 Likes

Here is a new version of my extension:

New blocks

Note:
If you do not use this (but the original version), you will get deviations when adding up the milliseconds, since the times displayed (in the ListViewer) are rounded down (i.e. that as long as a second has not yet ended (e.g. 1999ms are displayed as 1 sec).

Screenshot

2 Likes

Here is a blocks-only solution, which you can dress up as you like ...

total_duration.aia (5.9 KB)

1 Like

thank you all

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.