# Durations for certain tag value

**URL:** <https://forum.inductiveautomation.com/t/durations-for-certain-tag-value/83586>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [December 28, 2023, 8:48pm UTC](https://forum.inductiveautomation.com/t/durations-for-certain-tag-value/83586 "2023-12-28T20:48:35Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 28, 2023, 8:58pm UTC](https://forum.inductiveautomation.com/t/durations-for-certain-tag-value/83586/2 "2023-12-28T20:58:16Z")

</div>

> [@anthony\_ho](#):
>
> being logged OnChanged to the database.

Do you mean to the Ignition Historian? If so, then no. You will have to retrieve the records as stored and then write a script to calculate the totals.

You also now have the additional problem of figuring out what state the machine is in at the _start_ of the period of interest - particularly if it never changes state during the period.

The historian doesn't extrapolate data to the start and end timestamps and this makes it of little use (in my opinion) for many applications. As a result we're using a dedicated table to record tags onChange and on a gateway scheduled event (every 15 minutes in our case) so that we always have a value for the start of any shift pattern (which will always start / end at :00, :15, :30 or :45). The data table columns in our case are

- timestamp
- machineId
- runStatus
- stopCode (what was the first-out alarm that caused the machine to stop)
- countGood
- countTotal
- productCode

That gives a pile of useful information for OEE, etc.

---

_[View the full topic](https://forum.inductiveautomation.com/t/durations-for-certain-tag-value/83586)._
