Tinderbox Forum

Sum time intervals

I have been creating a time log with each task a note with key attributes of Priority (set), Period (interval), Task Type (set), and Mood (set).

This is an example of an agent and action I want to create:

Query: inside(Time Analysis) & $Priority==“Essential”;

Action: $MyNumber=sum(children,$Period)

Display Expression: $Name+"— Total Time= “+$MyNumber+” hours/minutes."

But Total Time keeps coming out zero, even though the query is finding all the right notes.


I believe sum() works on Number type data and you’re using Interval type. Have you tried turning the $Period into a number of minutes. You can then sum those, then turn them back nit hours/minutes or such.

Ideally, don’t do lots of calculation in the display expression. Instead use a user attribute to hold the computed value and them display that.

Mark, I changed to a Number type, reentered all the time periods as minutes and made the following changes:

Agent Query: $MyNumber=sum($Period); [before that I had tried $MyNumber=sum(children,$Period);

Then Display Expression: $Name+"— Total Time= “+$MyNumber+” minutes."

I still get zero, even though the query is finding all the correct instances.

Am I doing the sum right?


I got everything to work using the Dashboard prototype with a rule for subtitle.

What is the value of the $MyNumber attribute, i.e. before it is used in the display expression?

Your ‘agent query’ looks wrong. Don’t you mean the agent action? However, that’s not how you sum the agents children.

The query finds notes that match the query, make an alias of each as a child of the agent. The agent’s action is performed upon each of those aliases. However, you want the agent to show the sum of the child $Period values. For that, set the agent’s $Rule [sic] to:


The $MyNumber attribute for the agent should now hold that sum as an integer number. Now we add code to the same rule to make the overall display string:

$MyString = $Name+" – Total Time = "+floor($MyNumber/60)+"/"+mod($MyNumber,60)+" hours/minutes";

Lastly, in the display expression box on the text Inspector, you simply enter:


Thus if the the sum in the agent $MyNumber were 310 (minutes), $MyString would be Test cell – Total Time = 5/10 hours/minutes.

How’s that?

Thanks so much. I got everything to work with a rule to set subtitle as x.xx hours. I will modify to get hours and minutes instead, which I couldn’t figure out how to do before.