# Conditional Tag Write using time of day (TOD)

**URL:** <https://forum.inductiveautomation.com/t/conditional-tag-write-using-time-of-day-tod/17571>\
**Category:** General Discussion\
**Created:** [April 2, 2018, 7:16am UTC](https://forum.inductiveautomation.com/t/conditional-tag-write-using-time-of-day-tod/17571 "2018-04-02T07:16:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rwoolnough](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@rwoolnough](https://forum.inductiveautomation.com/u/rwoolnough)\
**Post date:** [April 2, 2018, 7:16am UTC](https://forum.inductiveautomation.com/t/conditional-tag-write-using-time-of-day-tod/17571/1 "2018-04-02T07:16:55Z")

</div>

Hi All,  
I have been trying to work out / locate an easy way to write a value to a PLC tag depending on the current time.  
I want to reset a total volume reading at midnight (every day). This reset is done in the PLC hence I am trying to set a Tag (Vol\_Reset) to the value 1. This tag is “Bool” so I want to turn it on (make it true / high).  
I have created a “memory tag” called ‘CurrentTime’ which is = now() and I have tried creating the scripting below with no success

if {‘CurrentTime’ == 00:00}:  
system.tag.write(‘PLC/Vol\_Reset’, 1)  
else:  
system.tag.write(‘PLC/Vol\_Reset’, 0)

Is there an easier way to achieve writing to a tag at a set time of day or date?

Thank you  
Woolie

---

<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:** [April 2, 2018, 12:04pm UTC](https://forum.inductiveautomation.com/t/conditional-tag-write-using-time-of-day-tod/17571/2 "2018-04-02T12:04:22Z")

</div>

The [now()](https://docs.inductiveautomation.com/display/DOC79/now) function returns a DateTime. You need to use [dateFormat()](https://docs.inductiveautomation.com/display/DOC79/dateFormat) to get the comparison in your code to work.

Alternatively, you could use a [transaction group](https://docs.inductiveautomation.com/display/DOC79/Understanding+Transaction+Groups). These groups can be scheduled to run at a specific time. So you could setup a group to write the tag to 1 at midnight, and then when the PLC has finished its processing let it set the value back to zero.

---

<div class="post-metadata">

**Author:** ![rwoolnough](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@rwoolnough](https://forum.inductiveautomation.com/u/rwoolnough)\
**Post date:** [April 2, 2018, 11:59pm UTC](https://forum.inductiveautomation.com/t/conditional-tag-write-using-time-of-day-tod/17571/3 "2018-04-02T23:59:27Z")

</div>

Thanks Brandon,  
I’ll give your suggestions a try.  
Thanks again for the help  
Woolie
