Hakan Axheim

Hakan Axheim

  • NA
  • 201
  • 32.9k

Extraction data from a Array to another wit filter

Nov 8 2017 9:11 AM
Hi,
 
I have some problem with my source code. It looks like this! 
 
const currentDate = moment().format('MM/DD/YYYY'); // Current Date
this.bookingsData = this.bookingsService.bookings;
this.bookingsDataFuture = this.bookingsData.filter(r => moment(r.periodEnd).format('MM/DD/YYYY') >= currentDate);
this.bookingsDataPast = this.bookingsData.filter(r => moment(r.periodEnd).format('MM/DD/YYYY') < currentDate);
In bookingsData I have three rows of appointments. All three in the future!
In bookingsDataFuture I want all bookings made in the future from current date.
In bookingsDataPast I want all bookings that have been in  the past.
 
Unfortunately only thow rows will be in the future and one of them in the past.
All three rows should be in the future.
 
This is my testdata and the result of the source code:
 
11/15/2017 (Future)
11/16/2017 (Future)
11/17/2017 (Past)

Answers (1)