Derived Date Tag

Having multiple issues with Datetime derived tag.

I’m reading and writing string-encoded UTC datetimes over OPC, and would like to use derived tags to both convert the strings to actual datetime types, while also offsetting them into the local timezone.
The read portion of this works fine, but when writing to the derived tag I get cryptic evaluation errors.

I have the following tags:

  • datetime_r - OPC - string
  • datetime_w - OPC - string
  • datetime_utc - Derived - DateTime - source is datetime_w
  • datetime - Derived - DateTime - source is datetime_utc

the write expression on my datetime tag:


The evaluation error reports: Invalid argument type for function null(date, int)

Is {value} not a string, and the result of toDate() not a datetime?

What’s the datatype of your datetime tag? String or DateTime?

What version of Ignition is this?

DateTime, updated my post for clarity.
Ignition version 7.9.10.

I don’t know if you figured this out. It doesn’t like the multiplication in the addHours part of the expression but if you wrap it in toInt() it will work. getTimezoneOffset returns a double while add hours is looking for an integer. When you do the multiplication it returns a double. Since addHours requires an int you got the error you showed.

The result is:

1 Like

Thanks, I hadn’t looked into this yet.

I’m leaning towards calling this a bug.

To me I think it is a bug. I wouldn’t think being a regular int vs a double should stop it from working but that was the only thing I could see that it could be. Forcing it to an int got past the error though.

Out of curiosity I just tried one more thing. I used:

	  toDate("2007-04-12 16:28:22"),

This also gets the expression error but if I add in the toInt it works fine. This takes away from my double vs int thought since I would assume -1 and 5 would both be looked at as int’s.