# Tag Event Script Value Changed But Only If Change Was X Minutes Ago

**URL:** <https://forum.inductiveautomation.com/t/tag-event-script-value-changed-but-only-if-change-was-x-minutes-ago/53272>\
**Category:** Ignition\
**Created:** [November 19, 2021, 2:38am UTC](https://forum.inductiveautomation.com/t/tag-event-script-value-changed-but-only-if-change-was-x-minutes-ago/53272 "2021-11-19T02:38:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![beckya](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@beckya](https://forum.inductiveautomation.com/u/beckya)\
**Post date:** [November 19, 2021, 2:38am UTC](https://forum.inductiveautomation.com/t/tag-event-script-value-changed-but-only-if-change-was-x-minutes-ago/53272/1 "2021-11-19T02:38:48Z")

</div>

Hello I am trying to record the timestamp when a boolean tag changes value, but only if the most recent change was more than x seconds ago. I am trying to exclude moments when the tag changes rapidly. Is there a way to do that?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/6/7696ec4ce11afb4c65f88d557fef90c2ddd71149.png)

---

<div class="post-metadata">

**Author:** ![beckya](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@beckya](https://forum.inductiveautomation.com/u/beckya)\
**Post date:** [November 19, 2021, 3:05am UTC](https://forum.inductiveautomation.com/t/tag-event-script-value-changed-but-only-if-change-was-x-minutes-ago/53272/2 "2021-11-19T03:05:04Z")

</div>

Is there anything that can be done with this?

time = currentValue.timestamp - previousValue.timestamp

---

<div class="post-metadata">

**Author:** ![michael2](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@michael2](https://forum.inductiveautomation.com/u/michael2)\
**Post date:** [November 19, 2021, 4:24am UTC](https://forum.inductiveautomation.com/t/tag-event-script-value-changed-but-only-if-change-was-x-minutes-ago/53272/3 "2021-11-19T04:24:37Z")

</div>

[https://docs.inductiveautomation.com/display/DOC80/system.date.\*Between](https://docs.inductiveautomation.com/display/DOC80/system.date.*Between)

Take a look at this.

---

<div class="post-metadata">

**Author:** ![beckya](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@beckya](https://forum.inductiveautomation.com/u/beckya)\
**Post date:** [November 19, 2021, 6:18pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-value-changed-but-only-if-change-was-x-minutes-ago/53272/4 "2021-11-19T18:18:40Z")

</div>

offTime = currentValue.timestamp  
onTime = previousValue.timestamp  
time = system.date.minutesBetween(onTime, offTime)

if currentValue.value == 1 and time \> 5:  
system.tag.write("[.]Direct Steam On Timestamp",system.date.now())

---

<div class="post-metadata">

**Author:** ![beckya](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@beckya](https://forum.inductiveautomation.com/u/beckya)\
**Post date:** [November 19, 2021, 6:19pm UTC](https://forum.inductiveautomation.com/t/tag-event-script-value-changed-but-only-if-change-was-x-minutes-ago/53272/5 "2021-11-19T18:19:28Z")

</div>

Thanks! This helped!
