Use Script to Show a Date in a Label in Vision

I have a table and allow the user to select rows. When the selected row changes I run a script to pull out and echo back to the user some values that will be changed.

I have no problem with text and integers, but the date is a problem.

I capture the date like this:

TimeStamp =, “Line State Event Begin”)

Then I try to writ it to a label on the screen like this:

event.source.parent.getComponent(‘LabelDate’).text = TimeStamp

Which give the error “TypeError: can’t convert Sun Jan 10 16:04:50 EST 2021 to java.lang.String”

If I instead write it to a date tag like this:
system.tag.write("[client]TimeStamp", TimeStamp)

and then use that tag in the label, then it works.

I want to write directly to the label.

I’m missing something simple, right?

I would try:

TimeStamp = str(, "Line State Event Begin"))

the python str function will explicitly cast the value to a string, which might work.

It will be easier for people to read your questions if you put any code inside a code block. Surround your code with three back ticks (```) on each side.

I’d probably use It returns a string and will let you format your string to look the way you want it.

1 Like

Thank you both, this is so helpful. I’ll be mindful of the code formatting as well.

Thanks again.

1 Like