Duration using MOD, but keeping 00.000 formatting

For capturing duration of processes I am using the MOD function to get the hours, minutes and seconds of duration between a 'start seconds and stop seconds' (see screenshot) . Seems I loose the ability to get the duration of seconds with decimal places showing correctly.
The result never shows the decimal places as being other than .000
Is there a way to keep that formatting (and actual numbers) in the result?
I'd like to see 1:12.777 or the like~ not 1:12.000

<img

I believe the problem is not with the formatting, but with the KM MOD operator.
It appears to return the Integer Floor of the Remainder, thus always truncating the decimals.

This example macro shows the issue.
My second Action (in yellow) does a manual calculation of the MOD function.

Example Macro

##example Results

Perhaps you can use this to revise your Macro.

1 Like

@peternlewis, is this a bug in KM, or just the way it is designed?

The KM MOD operator performs differently than the JavaScript % ("Remainder") operator, which I believe is the equivalent of the MOD operator.

See:

Syntax

Operator: var1 % var2
Examples

12 % 5 // 2
-1 % 2 // -1
NaN % 2 // NaN
1 % 2 // 1
2 % 3 // 2
-4 % 2 // -0
5.5 % 2 // 1.5

thanx JMichaelTX that worked fine. I had also worked out a ‘funky’ way to use getting a sub-string of a variable that worked but it was wonky, but, it worked.
Hey, how do you guys get the ‘@xxxxxname’ thing to be a link and in the grey background when you post?

1 Like

Just type "@", and you will see a popup list of UserNames.
Type enough characters to select the one you want, the press TAB
You can also type usernames that are NOT shown in the popup.

1 Like

nice, thanx

It is as designed. Internally it uses the C % operator which is only defined for integers.

You can preserve the fraction with something like:

Set variable Fractions to calculation All Seconds2 - TRUNC(All Seconds2)
Set variable All Seconds2 to TRUNC(All Seconds2) (not strictly necessary)
Set variable Seconds2 to (All Seconds2 MOD 60) + Fractions format 00.000

I assume you've already seen these plugins I posted, since you "liked" them, but in case anyone else is following along, I'll link them here:


2 Likes