# How can calculate run hour machine?

**URL:** <https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702>\
**Category:** Ignition\
**Created:** [February 28, 2020, 5:49pm UTC](https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702 "2020-02-28T17:49:16Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![soontosr](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@soontosr](https://forum.inductiveautomation.com/u/soontosr)\
**Post date:** [February 28, 2020, 5:49pm UTC](https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702/1 "2020-02-28T17:49:16Z")

</div>

ex. i have one tag ,

```
 if tag001 value is more than 10 ,meaning machine is run.
   tag001 value is less than 10 , menining machine is stop

 i want to check every day , how many hour machine run?
how can i do?

  thank you
```

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [February 28, 2020, 6:12pm UTC](https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702/2 "2020-02-28T18:12:39Z")

</div>

There are a number of different way. The easiest is using the built in tag history option that can be found in the tag editor. I am not sure if its part of the core Ignition Module or part of The SQL Bridge Module. You didn’t mention the version of Ignition you’re using. This does require an Historian database being set up.

You could use a transaction group. And clever queries to extract.

You could log it on a gateway tag change event script. And clever queries to extract.

---

<div class="post-metadata">

**Author:** ![soontosr](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@soontosr](https://forum.inductiveautomation.com/u/soontosr)\
**Post date:** [February 28, 2020, 6:14pm UTC](https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702/3 "2020-02-28T18:14:20Z")

</div>

thank you

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [February 28, 2020, 6:27pm UTC](https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702/4 "2020-02-28T18:27:01Z")

</div>

I would opt for transaction group, that way you can have it self manage the table (ie never keep records over 1 year or 6 months…).

---

<div class="post-metadata">

**Author:** ![soontosr](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@soontosr](https://forum.inductiveautomation.com/u/soontosr)\
**Post date:** [February 28, 2020, 6:30pm UTC](https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702/5 "2020-02-28T18:30:56Z")

</div>

normaly , hour meter should record begin start up machine.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 28, 2020, 6:37pm UTC](https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702/6 "2020-02-28T18:37:06Z")

</div>

Consider making a boolean expression tag that is true when the first tag is \>= 10. Then record in your DB whenever it changes. Then you can calculate from the DB. See also:

> [@Not sure if I'm using an hour meter transaction group properly](http://forum.inductiveautomation.com/t/not-sure-if-im-using-an-hour-meter-transaction-group-properly/32578/5):
>
> If you want to be precise, record every transition of your “Running” status in a table with a timestamp. Perform delta calculations from event to event, summing the deltas that are “true” at the start. (The lead() and lag() window aggregate functions in SQL are the most efficient means to do this, imnsho.) Clip the deltas to specific time periods to summarize by hour/shift/day/week/whatever.

---

<div class="post-metadata">

**Author:** ![soontosr](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@soontosr](https://forum.inductiveautomation.com/u/soontosr)\
**Post date:** [February 28, 2020, 6:46pm UTC](https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702/7 "2020-02-28T18:46:32Z")

</div>

i will try, thank you.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [February 28, 2020, 6:49pm UTC](https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702/8 "2020-02-28T18:49:04Z")

</div>

1. create expression tag
2. use this expression `if({yourTagPath} >=10,1,0)`
3. Use the tag as the trigger in the transaction group
4. Add any other tags you want to log along with machine status

---

<div class="post-metadata">

**Author:** ![rcrownover](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rcrownover/32/17805_2.png) [@rcrownover](https://forum.inductiveautomation.com/u/rcrownover)\
**Post date:** [February 28, 2020, 10:10pm UTC](https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702/9 "2020-02-28T22:10:41Z")

</div>

Also, if you wanted to avoid interfacing directly with a database (although that is the method I would use), you could create the boolean expression tag as described above and take tag history on it. Then pull that history and use expressions/scripts to evaluate the data in the dataset that’s returned by a tag history query.

---

<div class="post-metadata">

**Author:** ![soontosr](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@soontosr](https://forum.inductiveautomation.com/u/soontosr)\
**Post date:** [February 29, 2020, 2:34am UTC](https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702/10 "2020-02-29T02:34:48Z")

</div>

thank you very much. ^^

---

<div class="post-metadata">

**Author:** ![soontosr](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@soontosr](https://forum.inductiveautomation.com/u/soontosr)\
**Post date:** [February 29, 2020, 2:35am UTC](https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702/11 "2020-02-29T02:35:19Z")

</div>

thank you very much

---

<div class="post-metadata">

**Author:** ![soontosr](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@soontosr](https://forum.inductiveautomation.com/u/soontosr)\
**Post date:** [February 29, 2020, 2:55am UTC](https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702/12 "2020-02-29T02:55:21Z")

</div>

hi sir,  
3.Use the tag as the trigger in the transaction group  
how to config.?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/f85d8b92d0ab37ae28ad0129f12d5a8eaa4f0ece.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/cfc0e055ee97f292c5f87eadd02ace6a512f58f2.png)

thank you

---

<div class="post-metadata">

**Author:** ![Brian\_F](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@Brian\_F](https://forum.inductiveautomation.com/u/Brian_F)\
**Post date:** [March 5, 2020, 11:33pm UTC](https://forum.inductiveautomation.com/t/how-can-calculate-run-hour-machine/32702/13 "2020-03-05T23:33:20Z")

</div>

I have used this approach often. In order to ease reporting by shift, I have an additional tag change script running on my shift name tag that momentarily toggles the machine status tag value at shift change. Then, for reporting, I just filter those short duration (sub-second) status events. This makes sure that no long “running” or “down” conditions cross one or multiple shift boundaries and require more data massaging on the reporting side after the fact.
