Unable to convert to datatype DateTime

Just looking to do what i thought was simple task, setting a tag value to current date time with NOW(). Having no luck and tried all different forms of (NOW), date (NOW()), dateFormat…
Using the Event Handler - Set Tag Value, its worked great for everything else. I know it can be done as if you go to the Tag Editor - General Properties it allows you to set the value to Now. Any kick in the head as to what i am doing wrong?


Sounds like you’re trying to use functions from the expression language in a Jython script.

Is this an OPC tag you need to set the date on or could you get away with making a new expression tag and then using now() in that?

Yes, this is an OPC tag. Just a simple process, I thought. There’s button labelled ENTER, and when its clicked, the action does some other functions of moving data to other tags (these work fine), but cannot get the value (DateTime) to go to NOW() for another tag. It seems no matter what I have tried, I get the unable to convert error.

Thanks for the response.

Well, like I was saying, now() is a function of the expression language, not the scripting language.

Try something like this:

from java.util import Date

system.tag.write('path/to/date_tag', Date())