How to send date time as a parameter, vision popup

I am thinking of using a date time as a parameter for a popup, but I am not sure how to format it so that I only get the date time, and not all the extras.

I created a custom prop on the popup, eventTS, tried using the DATE type, then tried STRING, but neither works as is.

The line of thinking is I would like to grab the time stamp off a tag when it fires, then use the time stamp to update the associated record in the DB with additional info in the near future of the tag fire event.

Here is the error when using a DATE type custom prop:

ValueError: Error setting parameter: eventTS. Could not convert [[Wed Aug 28 13:17:23 PDT 2024, Good, Wed Aug 28 13:38:29 PDT 2024 (1724877509536)]] into Date.

EDIT:
I have a label bound to the "eventTS" prop, and here is what it looks like when using the STRING data type for the custom prop:
image

The error you are getting when using the DATE type is because you are passing the entire qualifiedValue object to the popup parameter.

Qualified values have value, quality, and timestamp members, so to get the timestamp maybe you need to use .timestamp, such as popupParam = currentValue.timestamp or similar.

1 Like

So the tag has a timestamp element. [Sample_Tags]Writeable/WriteableBoolean2.Timestamp
The value of this element should only be the timestamp, and you cannot add a .value or .timestamp to the end of it.

How are you sourcing this timestamp value? Are you calling system.tag.read*? Are you using a valueChange event and using currentValue.timestamp or currentValue.value?

If you are fetching the tag value via any system.tag.read* call it will return a list of qualifiedValue objects.

This means you will need to pull the object from the list and then either use .value or .timestamp to pull the preferred data. (i.e. popupParam = tagValues[0].timestamp)

currentValue is also a qualifiedValue, if you are using a change event script. That should allow you to just use currentValue.value or currentValue.timestamp

This would seem to indicate you are using a system.tag.read* call, as the data appears to be a qualifiedValue in a list.

Edit:
Quick script confirming my suspicion:

tagPath = "[Provider]Global/TestTypeID.Timestamp"
tagValues = system.tag.readBlocking([tagPath])
print tagValues
print tagValues[0]
print tagValues[0].value

Nets the following in the console:

>>> 
[[Mon Aug 26 17:14:18 EDT 2024, Good, Wed Aug 28 21:17:11 EDT 2024 (1724894231151)]]
[Mon Aug 26 17:14:18 EDT 2024, Good, Wed Aug 28 21:17:11 EDT 2024 (1724894231151)]
Mon Aug 26 17:14:18 EDT 2024
>>> 

Note how the first console line matches the data format shown in your error message. Use eventTS = tagValues[0].value to assign the actual date object to the parameter.

3 Likes

You can read the tag itself, then extract the timestamp from the qualified value:

system.tag.readBlocking([your_tag])[0].timestamp
==
system.tag.readBlocking([your_tag.timestamp])[0].value
2 Likes

Um, yep, missed the list part. Thanks!