I know this is a very popular problem, but here goes. So I have an array of records coming in and need to filter them. I am filtering them by date, and I need them to be <=7 and >=1 days from today()s date.
const Today = new Date();
const thirtyday = Today - 30;
const sevenday = Today - 7;
const oneday = Today - 1;
const machinerecords = this.state.tasksnfiltered;
const due = machinerecords.filter(
(record) =>
Date.parse(record.nextdue) <= sevenday &&
Date.parse(record.nextdue) >= oneday
);
{
this.setState({ due: [...due] });
}
I have also tried
machinerecords
.filter((record) => Date.parse(record.nextdue) <= thirtyday)
.filter((record) => Date.parse(record.nextdue) >= sevenday);
The info is coming from a backend I built.
I can get the first filter to run alone accurately for any of the date filters. but cant combine them.