Tag History Query - Scripting - Single Closest Value

I’m attempting to query for the historical value of an integer tag at one single point in time, but am drawing a blank since “ClosestValue” is not available as an aggregation mode through scripting.

Found a similar question but no responses: History tag, single value?

Any ideas, or am I trying something that shouldn’t be necessary?

Thanks!

Some additional details:

The integer is essentially a code or enum for a machines status.
The historian properties are as follows:

  • Deadband = 1.0
  • Deadband Mode = Absolute
  • Max time between records = Unlimited
  • Timestamp Source = System
  • Value Mode = Discrete

I’m not sure if the historian is the best way to store this information, or if I’d be better off using my own SQL tables and on-change event scripts.

LastValue is the scripting equivalent of Closest Value.

https://docs.inductiveautomation.com/display/DOC79/system.tag.queryTagHistory

1 Like