ValueAtTime

This function maintains a set of values and their timestamps. When a value is added to this set, any value that has a timestamp older than the newest timestamp minus the specified interval will be removed from the set. The function returns the oldest value in the set.

Syntax

ValueAtTime ( value, valueTimestamp, interval, defaultValue)

Remarks

The value parameter specifies the data value for which the set of values is maintained. The valueTimestamp is the timestamp for this data value. (The Timestamp function can be used to obtain this timestamp.) The interval parameter is the time interval, in nanoseconds, over which the set is maintained. The predefined time constants can be used to easily input the number of nanoseconds in a microsecond (nsecPerUSec), millisecond (nsecPerMSec), second (nsecPerSec), minute (nsecPerMin), hour (nsecPerHour), day (nsecPerDay), or week (nsecPerWeek). The defaultValue parameter is the value that will be returned, if the set isn’t full.

Examples

The following expression returns the value of Temp_F at the current time but one day earlier. (The StartRelativeToNewest function backfills the data set initially to the full 24 hour interval, provided that the data is available in the data source.)

StartRelativeToNewest(nSecPerDay,OrderCollected);ValueAtTime("Server:CR1000.Hourly.Temp_F",Timestamp("Server:CR1000.Hourly.Temp_F"),nsecPerDay, $"invalid")