Date/Time Tag from Scheduled Gateway Event

Hello,

I am trying to create a script that writes the date/time to a tag at that scheduled event. Here's what I have but I keep getting "TypeError: expected a str".
I have tried the destination tagpath as both Date/time and String.

def onScheduledEvent():
rightNow = system.date.now()
nowTag = system.tag.readBlocking(['[default]plant/shift/shiftStartTime)'])
system.tag.writeBlocking(nowTag,rightNow)

You don't need to read the tag to write to it

system.tag.writeBlocking(['[default]plant/shift/shiftStartTime)'],[rightNow])
1 Like

system.tag.readBlocking() returns a list of QualifiedValues.

system.tag.writeBlocking() takes a list of tagPaths, and a List of values. As @dkhayes117 has shown.

To get the value read from a tag you need to get it from the list, and then refernece the value property of the QualifiedValue.

system.tag.readBlocking(['[default]plant/shift/shiftStartTime'])[0].value

https://docs.inductiveautomation.com/display/DOC81/Scripting+Object+Reference#ScriptingObjectReference-QualifiedValue

For what you're showing here, you don't actually need to read the tag though.

Unless there is some other logic you are wanting to perform.