I have a table component that I’m using in perspective where one column needs to show a date. When viewing the value in the dataset editor, the date shows up as “7/2/20, 7:52:04 AM” as I would expect.
However, where that same data is displayed in the Perspective table, the value is showing as “1,593,690,724,000”
What do I need to do so that the column in the table matches the date value in the dataset editor?
As it turns out, there is a function for that specific purpose: system.dataset.formatDates()
It can be used as a transform for the dataset binding like in the picture below:
Hope this helps!
And what if we want it to affect only one column of the table?
Did you get answer for your question?
For that setting to have any effect in this case, “date” must be selected as the render type. If a “date” type is what is supplied, then that setting would work, but the incoming value is a date value described as an integer.
So set the
render property to “date”, and set the
dateFormat property to the format you’d like to have displayed.
Yes, thanks, i didn’t point the column in the table.
There still seems to be something a bit messed up about this. I get the Epoch date display format to update only by creating the column properties (as shown above) but only making sure the column name of the query matches the column name of the table column property - before changing the render type. This implies that Ignition already can figure out to “auto” change the display type, but why it only does it at this point??
Also: somewhere along the script:
data = self.getSibling(“Table”).props.data
Excel_xlsx = system.dataset.toExcel(True,[data])
DOES convert the date format automatically, even when it’s not converted in the table’s visual display.
I am having the same issues here, I have tried many things including changing the render to date, and selecting dateFormat in my table but nothing changes the integer time to datetime. the data recieved is in the form of java date so I am not sure what my problem is.
Could you please share some screenshots and code snippets that display your undesired behavior? It’s important for us to see the structure of your data as well as the configuration of your column, and also a screenshot of the appearance of the Table.
Image of the table Since, ETA columns are the ones in question
A named query is providing data that is pulled by this script:
and it is bring written to a memory tags, that are then bound to the table
this is the column configuration
The problem is due to the fact that while you have x number of columns configured, you have not explicitly specified which column should use those settings. Set
columns.field to a value of “ETA” and you should see the column use a date render mode.
Edit: Sorry, column 6.
From the documentation:
- Next we need to map each props.column element to a column in our underlaying data (props.data). For each props.columns[#].field property, set the field property to the name of a column/series in our props.data property. For example, if we’re using the default dataset on the component and we wanted the column order to be country , city , and then population , we would set
props.columns.[ 0 ].field to country
props.columns.[ 1 ].field to city
props.columns.[ 2 ].field to population
Maybe this is mentioned elsewhere, but beware that the field entry is case sensitive. If you misspell it or use wrong case, you will get the default for that column, which, in many cases for me, is the same thing (because I just put the columns in the same order as the fields that come out of the query)
Once I matched case in field, suddenly all the date formats rendered as I wanted them to.