I'm trying to filter the date which where the FROM and TO will display the data,
but when the FROM and TO are the same it doesn't display the current date selected.
Example FROM: 08-01-2019 00:00:00 | To: 08-29-2019 13:00:00 it doesn't display the data 2019-08-28 12:36:01, but when I try to set the FROM: 06-14-2019 00:00:00 | TO: 08-29-2019 13:00:00 it displays all the data
templog.component.ts
columnDefs: any = [
{ headerName: 'Date Time', field: 'dateandtime' },
{ headerName: 'Location', field: 'sensor' },
{ headerName: 'Temperature', field: 'temperature' },
{ headerName: 'Humidity', field: 'humidity' }
];
submitForm(): void {
this.rowData = record.default.records;
const dateStart = format(this.validateForm.value.datePickerStart, 'YYYY-MM-DDTHH:mm:ss');
const dateEnd = format(this.validateForm.value.datePickerEnd, 'YYYY-MM-DDTHH:mm:ss');
for(let i = 0;i < this.rowData.length; i++){
if (isBefore(this.rowData[i].dateandtime, dateStart) ||
isAfter(this.rowData[i].dateandtime, dateEnd )) {
this.rowData = this.rowData.splice(i, 0);
}
}
}
templog.json
{
"records": [
{
"dateandtime": "2018-06-14 01:38:02",
"sensor": "Sewing Line1",
"temperature": "25.8",
"humidity": "99.9"
},
{
"dateandtime": "2018-06-14 01:36:01",
"sensor": "Sewing Line1",
"temperature": "25.8",
"humidity": "99.9"
},
{
"dateandtime": "2018-06-14 01:36:01",
"sensor": "Heat Seal Area",
"temperature": "25.9",
"humidity": "99.9"
},
{
"dateandtime": "2019-08-28 12:36:01",
"sensor": "Heat Seal Area",
"temperature": "25.9",
"humidity": "99.9"
}
]
}
i--after removal.filter