# How to make the script run time change

**URL:** <https://forum.inductiveautomation.com/t/how-to-make-the-script-run-time-change/35580>\
**Category:** Ignition\
**Created:** [June 12, 2020, 4:49am UTC](https://forum.inductiveautomation.com/t/how-to-make-the-script-run-time-change/35580 "2020-06-12T04:49:59Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oleh](https://avatars.discourse-cdn.com/v4/letter/o/b4bc9f/32.png) [@Oleh](https://forum.inductiveautomation.com/u/Oleh)\
**Post date:** [June 12, 2020, 4:49am UTC](https://forum.inductiveautomation.com/t/how-to-make-the-script-run-time-change/35580/1 "2020-06-12T04:49:59Z")

</div>

Hello. I have a gateway script that fires at a given time. How can I make a given time tied to a tag? I need to change the execution time of a script by entering the time in a memory tag.

````auto
type or paste code here
```from time import localtime, strftime 
curTime = strftime("%H:%M", localtime())
if curTime == "07:47":
	PR_value = system.tag.read('[default]TESTSTARTSTOP/09:00').value
	tags = ['[default]TESTSTARTSTOP/Active power9']
	values = [PR_value]
	system.tag.writeAll(tags, values)
````

---

<div class="post-metadata">

**Author:** ![Oleh](https://avatars.discourse-cdn.com/v4/letter/o/b4bc9f/32.png) [@Oleh](https://forum.inductiveautomation.com/u/Oleh)\
**Post date:** [June 12, 2020, 5:33am UTC](https://forum.inductiveautomation.com/t/how-to-make-the-script-run-time-change/35580/2 "2020-06-12T05:33:03Z")

</div>

I need instead of the value “07:47” to take the values ​​of the memory tag.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 12, 2020, 5:51am UTC](https://forum.inductiveautomation.com/t/how-to-make-the-script-run-time-change/35580/3 "2020-06-12T05:51:46Z")

</div>

```auto
from time import localtime, strftime 
curTime = strftime("%H:%M", localtime())
setpointTime = strftime("%H:%M", system.tag.read("[default]DateTypeMemoryTag").value)
if curTime == setpointTime:
	PR_value = system.tag.read('[default]TESTSTARTSTOP/09:00').value
	tags = ['[default]TESTSTARTSTOP/Active power9']
	values = [PR_value]
	system.tag.writeAll(tags, values)

```

No?

---

<div class="post-metadata">

**Author:** ![Oleh](https://avatars.discourse-cdn.com/v4/letter/o/b4bc9f/32.png) [@Oleh](https://forum.inductiveautomation.com/u/Oleh)\
**Post date:** [June 12, 2020, 5:56am UTC](https://forum.inductiveautomation.com/t/how-to-make-the-script-run-time-change/35580/4 "2020-06-12T05:56:47Z")

</div>

> [@nminchin](#):
>
> from time import localtime, strftime curTime = strftime("%H:%M", localtime()) setpointTime = strftime("%H:%M", system.tag.read("[default]DateTypeMemoryTag").value) if curTime == setpointTime: PR\_value = system.tag.read('[default]TESTSTARTSTOP/09:00').value tags = ['[default]TESTSTARTSTOP/Active power9'] values = [PR\_value] system.tag.writeAll(tags, values)

Error  
Traceback (most recent call last):  
File "", line 3, in   
TypeError: strftime(): 2nd arg can't be coerced to org.python.core.PyTuple

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 12, 2020, 5:58am UTC](https://forum.inductiveautomation.com/t/how-to-make-the-script-run-time-change/35580/5 "2020-06-12T05:58:46Z")

</div>

```auto
from time import localtime, strftime 
curTime = system.date.format(system.date.now(), 'HH:mm')
setpointTime = system.date.format(system.tag.read("[default]DateTypeMemoryTag").value, 'HH:mm')
if curTime == setpointTime:
	PR_value = system.tag.read('[default]TESTSTARTSTOP/09:00').value
	tags = ['[default]TESTSTARTSTOP/Active power9']
	values = [PR_value]
	system.tag.writeAll(tags, values)

```

---

<div class="post-metadata">

**Author:** ![Oleh](https://avatars.discourse-cdn.com/v4/letter/o/b4bc9f/32.png) [@Oleh](https://forum.inductiveautomation.com/u/Oleh)\
**Post date:** [June 12, 2020, 6:01am UTC](https://forum.inductiveautomation.com/t/how-to-make-the-script-run-time-change/35580/6 "2020-06-12T06:01:48Z")

</div>

> [@nminchin](#):
>
> from time import localtime, strftime curTime = strftime("%H:%M", localtime()) setpointTime = system.date.format(system.tag.read("[default]DateTypeMemoryTag").value, 'HH:mm') if curTime == setpointTime: PR\_value = system.tag.read('[default]TESTSTARTSTOP/09:00').value tags = ['[default]TESTSTARTSTOP/Active power9'] values = [PR\_value] system.tag.writeAll(tags, values)

there is no error, it does not work.  
What type of tag do I need to enter the time?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 12, 2020, 6:02am UTC](https://forum.inductiveautomation.com/t/how-to-make-the-script-run-time-change/35580/7 "2020-06-12T06:02:38Z")

</div>

You need to make your memory tag a Date data type. Is that what you have?  
Also, what are the settings you’ve configured on the gateway script? i.e. execution rate, etc. got a screenshot?

---

<div class="post-metadata">

**Author:** ![Oleh](https://avatars.discourse-cdn.com/v4/letter/o/b4bc9f/32.png) [@Oleh](https://forum.inductiveautomation.com/u/Oleh)\
**Post date:** [June 12, 2020, 6:20am UTC](https://forum.inductiveautomation.com/t/how-to-make-the-script-run-time-change/35580/8 "2020-06-12T06:20:57Z")

</div>

Thank`s. The script worked.  
Is it possible to enter into the memory tag with the data type data not the whole date “Fri Jun 12 09:08:20 EEST 2020” ?.I need to enter only time HH:mm to memory tag.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 12, 2020, 6:24am UTC](https://forum.inductiveautomation.com/t/how-to-make-the-script-run-time-change/35580/9 "2020-06-12T06:24:29Z")

</div>

You could use a string type and just enter that in. You would need to ensure that it’s entered in the correct format though. You could use the [formatted input field](https://docs.inductiveautomation.com/display/DOC80/Vision+-+Formatted+Text+Field) with the right format mask expression (e.g. `##:##`), if this is something you want to display on the screen for editing.

Then you would just use:

```auto
from time import localtime, strftime 
curTime = system.date.format(system.date.now(), 'HH:mm')
setpointTime = system.tag.read("[default]StringTypeMemoryTag").value # assumes value in the format "HH:mm"
if curTime == setpointTime:
	PR_value = system.tag.read('[default]TESTSTARTSTOP/09:00').value
	tags = ['[default]TESTSTARTSTOP/Active power9']
	values = [PR_value]
	system.tag.writeAll(tags, values)

```

You could do some error checking in the script to check format if you wanted to

---

<div class="post-metadata">

**Author:** ![Oleh](https://avatars.discourse-cdn.com/v4/letter/o/b4bc9f/32.png) [@Oleh](https://forum.inductiveautomation.com/u/Oleh)\
**Post date:** [June 12, 2020, 6:30am UTC](https://forum.inductiveautomation.com/t/how-to-make-the-script-run-time-change/35580/10 "2020-06-12T06:30:38Z")

</div>

Thank you so much!

---

<div class="post-metadata">

**Author:** ![Oleh](https://avatars.discourse-cdn.com/v4/letter/o/b4bc9f/32.png) [@Oleh](https://forum.inductiveautomation.com/u/Oleh)\
**Post date:** [June 17, 2020, 8:17am UTC](https://forum.inductiveautomation.com/t/how-to-make-the-script-run-time-change/35580/11 "2020-06-17T08:17:27Z")

</div>

How to control the execution of this script and if the value is not recorded make one more record of this value after 5 minutes?
