# Hold Value for 24 Hours

**URL:** <https://forum.inductiveautomation.com/t/hold-value-for-24-hours/43995>\
**Category:** Ignition\
**Created:** [March 2, 2021, 3:47pm UTC](https://forum.inductiveautomation.com/t/hold-value-for-24-hours/43995 "2021-03-02T15:47:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bennettr](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@bennettr](https://forum.inductiveautomation.com/u/bennettr)\
**Post date:** [March 2, 2021, 3:47pm UTC](https://forum.inductiveautomation.com/t/hold-value-for-24-hours/43995/1 "2021-03-02T15:47:51Z")

</div>

Hello, I’m looking for some guidance on the following issue…hoping to do this with an expression tag or a tag event script on an OPC tag that writes to 2nd tag.

I have a “lifetime counter” tag that is totaling by the minute but never resets. I’m looking to hold the value from the previous day so that I can have a tag that calculates Current value-previous day= daily amount.

Don’t want to create a transaction group for this either

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [March 2, 2021, 4:01pm UTC](https://forum.inductiveautomation.com/t/hold-value-for-24-hours/43995/2 "2021-03-02T16:01:22Z")

</div>

I’d use a gateway timer script and move the value into a memory tag to use in the project. I have a number of things I do like that over night to prepare for the next day. You can do a tag event script on an expression looking for a set time of day but my personal preference is to do it through a gateway script that looks for a set time. Something like what I have below running in a gateway timer script would do it.

```auto
hour = system.date.getHour24(system.date.now())
min = system.date.getMinute(system.date.now())

if hour == 3 and min == 0:
	r = system.tag.readBlocking(['yourCounterTag'])[0].value
	w = system.tag.writeBlocking(['memoryTag'],[r])

```

---

<div class="post-metadata">

**Author:** ![bennettr](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@bennettr](https://forum.inductiveautomation.com/u/bennettr)\
**Post date:** [March 2, 2021, 4:19pm UTC](https://forum.inductiveautomation.com/t/hold-value-for-24-hours/43995/3 "2021-03-02T16:19:35Z")

</div>

@bpreston Thanks for the help, got it to work!
