# How to get working Hours base on Boolean status

**URL:** <https://forum.inductiveautomation.com/t/how-to-get-working-hours-base-on-boolean-status/50364>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [August 26, 2021, 11:02pm UTC](https://forum.inductiveautomation.com/t/how-to-get-working-hours-base-on-boolean-status/50364 "2021-08-26T23:02:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamshidzade](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jamshidzade/32/24927_2.png) [@jamshidzade](https://forum.inductiveautomation.com/u/jamshidzade)\
**Post date:** [August 26, 2021, 11:02pm UTC](https://forum.inductiveautomation.com/t/how-to-get-working-hours-base-on-boolean-status/50364/1 "2021-08-26T23:02:16Z")

</div>

I know there is an Hours meter on the transaction group, but I need to know how I can show the working hours in SCADA page,  
we have a washing system that washes something for 10 minutes or less this machine working 12 hours or 13 hours per day, we need to know how many hours operations put the machine in washing mode

we have Boolean and I added Boolean to the transaction group, the question is how I can show working Hours on SCADA pages? How we can use transaction group result

---

<div class="post-metadata">

**Author:** ![Shaheryar\_Ahmad](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Shaheryar\_Ahmad](https://forum.inductiveautomation.com/u/Shaheryar_Ahmad)\
**Post date:** [December 11, 2022, 4:11pm UTC](https://forum.inductiveautomation.com/t/how-to-get-working-hours-base-on-boolean-status/50364/2 "2022-12-11T16:11:31Z")

</div>

Hi @jamshidzade

Have you got solution your question?

Actually I have similar kind of requirement where I want to record the duration of our machines towerlights status. Like when the batch started, how much time (in minutes) the machine is currently on the Green Light (running state), or on the Red Light (fault state) or on the Yellow light (standby/stopped by the operator).

As, this duration will help me in the OEE calculation.

---

<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:** [December 11, 2022, 5:27pm UTC](https://forum.inductiveautomation.com/t/how-to-get-working-hours-base-on-boolean-status/50364/3 "2022-12-11T17:27:51Z")

</div>

Use a transaction group that has an on-change trigger for the boolean or integer of interest. Have the transaction group check the trigger as a pace that meets your accuracy requirements. Then query the database, using a LEAD() window function to look forward from an event to grab the timestamp of the next one. Use an outer query to compute the durations grouped by event value, discarding the grouped rows that aren't interesting.

The insertions into the database can also be scripted if the SQL Bridge module is not installed/licensed.

There are numerous topics on this forum with sample SQL to convert events into durations. Some of these, perhaps:

[https://forum.inductiveautomation.com/search?q=%20lead%20downtime%20order%3Alatest](https://forum.inductiveautomation.com/search?q=%20lead%20downtime%20order%3Alatest)

Also, @Shaheryar_Ahmad, you asked this question in another topic:

> [@Multiple Tag Event Scripts Running Continuously and Not Breaking a/c to its logic](https://forum.inductiveautomation.com/t/multiple-tag-event-scripts-running-continuously-and-not-breaking-a-c-to-its-logic/67464):
>
> Hi Everyone, Hope you all are doing well. I am facing a weird issue on doing scripting work on 'Tag Event Script (on Value Change)'. Help and Guide needed for resolving it. My Task I have a expression tag of machine's tower light running ON/OFF status. I want to record its ON state duration, like how much time in minutes the light has been in ON state, into a separate memory tag named 'Running\_duration'. The duration will be recorded in minutes only if the running light state exceeds more t…

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [December 12, 2022, 8:37am UTC](https://forum.inductiveautomation.com/t/how-to-get-working-hours-base-on-boolean-status/50364/4 "2022-12-12T08:37:39Z")

</div>

I use a UDT with three tags, tag A is the cumulative time, tag B is the last Up time, and the tag C is the current state. Then update A, B in C's value change script.  
I only have perspective and historian modules. (and drivers)
