That worked, thank you. My other problem now is the function is not returning the formatted date. Here is my updated code:
import { Table, Smart } from ‘smart-webcomponents-react/table’;
…
const columns = [
{
label: ‘First name’,
dataField: ‘FirstName’,
dataType: ‘string’
},
{
label: ‘Last Name’,
dataField: ‘LastName’,
dataType: ‘string’
},
{
label: ‘Appointment’,
dataField: ‘Appointment’,
//dataType: ‘date’,
formatFunction: function (settings) {
const formatedDate = new Smart.Utilities.DateTime(settings.value).toString(‘MM/dd/yyyy ‘);
console.log(formatedDate);
settings.template = <div>${formatedDate}</div>
}
},
In the table, the date displays as: 2022-12-01T15:10:34.433Z
In the console it logs properly as: 12/02/2022.
It should display in the table as 12/02/2022, what am I doing wrong? Do I need to return something from formatFunction? I’m not setting a dataType for the Appointment column.
The data is coming in from SQL:
SELECT
FirstName,
LastName,
getdate() AS Appointment
FROM Person