# Calculate runtime percentage

**URL:** <https://forum.inductiveautomation.com/t/calculate-runtime-percentage/16393>\
**Category:** Ignition\
**Created:** [December 21, 2017, 4:15pm UTC](https://forum.inductiveautomation.com/t/calculate-runtime-percentage/16393 "2017-12-21T16:15:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bwagner](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bwagner](https://forum.inductiveautomation.com/u/bwagner)\
**Post date:** [December 21, 2017, 4:15pm UTC](https://forum.inductiveautomation.com/t/calculate-runtime-percentage/16393/1 "2017-12-21T16:15:43Z")

</div>

I have a Boolean historical tag that is 1 when machine starts and 0 when it stops. I wanted to calculate the percentage of time that it is running over a certain time period. Anyone have any ideas how to calculate that? Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [December 21, 2017, 5:35pm UTC](https://forum.inductiveautomation.com/t/calculate-runtime-percentage/16393/2 "2017-12-21T17:35:42Z")

</div>

Try using [system.tag.queryTagHistory](https://docs.inductiveautomation.com/display/DOC79/system.tag.queryTagHistory).  
It has an option that allows you to get the duration (in seconds) that the machine was on.  
You can then divide that by the length of your time period in seconds to get an estimated running percentage.

---

<div class="post-metadata">

**Author:** ![bwagner](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bwagner](https://forum.inductiveautomation.com/u/bwagner)\
**Post date:** [December 29, 2017, 6:31pm UTC](https://forum.inductiveautomation.com/t/calculate-runtime-percentage/16393/3 "2017-12-29T18:31:16Z")

</div>

That worked. Thank you
