Data Type Conversion

I have a memory tag containing realtime timestamps of specific data. The memory tag is of string type, and I need to convert it to DateTime so that I can visualize it in charts. The data format of the memory tag is "2024-06-26 23:24:40 +0530".

What do you mean "input memory tag" ?

Do you mean it's an input box on the screen?

no i meant normal memory tag. i mentioned input because it contains an incoming real time data

Where's the data coming from?

Its coming from the gateway (multiple users). I have created a reference tag for it and is utilizing it.
I need to convert the string datatype to DateTime.

You'll need to script it, as there is no expression function to do it.

EDIT: Fixed error in script.

def parseDate(stringIn):
	format = 'yyyy-MM-dd HH:mm:ss Z'
	return system.date.parse(stringIn, format)

I have to script it in the scripting section in the project browser?
How do i call the script in my tag after that?

Since we are doing this through the tag system, it would have to be added to your Global Scripting Project.

Then you can use an expression tag with an expression similar to:
runScript('util.parseDate',0,{path.to.your.referece.tag})

If you make a UDT out of it, you can then make as many instances as you need.

It is giving Error_ExpressionEval.


Click on the diagnostic button on the tag, and show what it says.

Sorry, misspelling on script above. Fixed it. Try that one instead.

That's what I get for spitting an example out before going to a meeting. :roll_eyes:

Thank you for your response. I'll try that out.