
Re: Any ideas on how to utilize time as a variable in a Pi Calculation?
kduffy Feb 12, 2019 6:45 PM (in response to johnflaherty)2 of 2 people found this helpfulHi John,
The way to reference the current time is '*', today at midnight is 't', and tomorrow at midnight is 't+1d'. Therefore, (time left today) would be 't+1d'  '*'.
I've added this equation to a PI Calc dataset and trended it:
And you can see that at midnight each day it spikes to 86400 (seconds), then slowly comes down to 0 for the next midnight:
For your dataset, you can wrap this in a set of parentheses and multiple it by your flow rate value (adjusting the time units, of course, incase your flow rate is not in a volume/second), and then adding your current total. Something like this:
'currentFlowRateTag'*('t+1d''*') + 'currentTotalTag'
Kelsey

Re: Any ideas on how to utilize time as a variable in a Pi Calculation?
tramachandran Feb 12, 2019 6:58 PM (in response to johnflaherty)2 of 2 people found this helpfulTime Expressions 't' and '*' denote midnight of today and current time respectively.
If you are looking ahead then 't +1d' would be the upcoming midnight.
Time left for today example:(There are also other ways to achieve the same result.)
DaySec returns the number of seconds since midnight.
86400 = 60*60*24 = Seconds in a day.
You can apply any conversion on seconds to get the desired time units.

Re: Any ideas on how to utilize time as a variable in a Pi Calculation?
TimCarmichael Feb 12, 2019 9:06 PM (in response to johnflaherty)1 of 1 people found this helpfulFirst, Kelsey's reply provides a visual demonstration of the principles of time manipulation.
Second, Thyagarjan's example show the basics with an analysis.
However, from having worked with system that are affected by daylight savings time or the return to standard time, I tend to stay away from 'magic numbers'; here 86400 is the number of seconds in MOST days  except when a time adjustment comes into play.
To that extent, you would be better off using 't' for today and 't+1d' for the upcoming midnight.
So: TimeLeft ==> ParseTime(Text('t+1d'  't'  DaySec('*')))
't+1d' 't' returns a timestamp; DaySec is a seconds value; create a text, then force it all to a timestamp
SecondsLeft ==> Hour(TimeLeft) * 3600 + Minute(TimeLeft) * 60 + Second(TimeLeft)
this returns the number of seconds left in the day as a numeric value