Here is a table I am currently working with:
ID DateColumn
1 3/7/2019 5:29:38 AM
2 3/8/2019 5:28:38 AM
3 3/7/2019 5:30:38 AM
4 3/7/2019 5:31:38 AM
The date column in this table is being processed as a string when bound to the grid. To effectively sort the data, I need to convert these strings into dates.
I have attempted to write code for this task:
getServiceResults() {
this.serviceCheckService.getResults(Appconfig.PageSize, Appconfig.PageNo).takeUntil(this.ngUnsubscribe).subscribe((data) => {
this.resultData = data;
this.resultData.forEach(x => x.DateColumn = new Date(x.DateColumn));
});
}
Unfortunately, the above code is producing a syntax error. Can you provide guidance on how to properly convert each value in the date column from a string to a date, and then proceed with sorting that column?