# Use Script to Show a Date in a Label in Vision

**URL:** <https://forum.inductiveautomation.com/t/use-script-to-show-a-date-in-a-label-in-vision/42114>\
**Category:** Ignition\
**Created:** [January 11, 2021, 3:09pm UTC](https://forum.inductiveautomation.com/t/use-script-to-show-a-date-in-a-label-in-vision/42114 "2021-01-11T15:09:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bill\_S](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bill_s/32/6705_2.png) [@Bill\_S](https://forum.inductiveautomation.com/u/Bill_S)\
**Post date:** [January 11, 2021, 3:09pm UTC](https://forum.inductiveautomation.com/t/use-script-to-show-a-date-in-a-label-in-vision/42114/1 "2021-01-11T15:09:24Z")

</div>

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 = table.data.getValueAt(table.selectedRow, “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?

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [January 11, 2021, 3:12pm UTC](https://forum.inductiveautomation.com/t/use-script-to-show-a-date-in-a-label-in-vision/42114/2 "2021-01-11T15:12:30Z")

</div>

I would try:

```auto
TimeStamp = str(table.data.getValueAt(table.selectedRow, "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.

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [January 11, 2021, 3:31pm UTC](https://forum.inductiveautomation.com/t/use-script-to-show-a-date-in-a-label-in-vision/42114/3 "2021-01-11T15:31:51Z")

</div>

I’d probably use [system.date.format()](https://docs.inductiveautomation.com/display/DOC81/system.date.format). It returns a string and will let you format your string to look the way you want it.

---

<div class="post-metadata">

**Author:** ![Bill\_S](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bill_s/32/6705_2.png) [@Bill\_S](https://forum.inductiveautomation.com/u/Bill_S)\
**Post date:** [January 11, 2021, 4:18pm UTC](https://forum.inductiveautomation.com/t/use-script-to-show-a-date-in-a-label-in-vision/42114/4 "2021-01-11T16:18:05Z")

</div>

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

Thanks again.
