Time duration

I am Implementing a tracker system with start-time and end-time data elements, How can I get the difference between the two time defined above?

1 Like

Hi @stephen_ogolla
Welcome to the community! :tada:

Please have you tried creating a program indicator for this purpose? I suggest creating a program indicator:

expression: end-time - start-time

Hope this helps!

I have tried that but I get this error.

What is the value type for these two data elements? I tried the same expression for two DEs whose type is Number and it worked. And in the screenshot it shows that the subtraction is from the same data element (LHS == RHS?)

The value type is time

We can’t directly subtract two values of the type time; however, if you are willing to use date & time data element type then it’s possible to use d2 functions such as d2:minutesBetween.

Other than that I tried to use program rules to ‘convert’ the time to a number but it caused many errors.

Either way, I’m asking @jason if there’s a way. Thanks!

I will appreciate.

1 Like

@stephen_ogolla sorry to say that duration calculation using time data element doesn’t seem possible.

Tagging @Markus who knows much more about the program rule engine than myself for a definitive answer!

1 Like