I want to read the data between the range as selected by user, but I am not able to get start and end date as selected. Although in console I am able to see it in moment, But don't know how can we get those dates and perform queries. Also get the dates in between selected range. For ex: below : should return betweendates = [7/11/19 , 8/11/19]

Here console log

<input type="text" matInput
    ngxDaterangepickerMd
    [locale]="{applyLabel: 'ok', format: 'DD-MM-YYYY'}"
    startKey="startDate"
    endKey="endDate"
    [(ngModel)]="selectedDaterange"
    name="daterange"
    (change)= 'selectDateRange()'
    placeholder="choose date"/>  
selectDateRange() {
    console.log(moment().format());
    console.log(this.selectedDaterange);
}

1

There are 1 answers

5
Athanasios Kataras On BEST ANSWER

You can use the following to get the javascript Date object

this.selectedDaterange.startDate.toDate();
this.selectedDaterange.endDate.toDate();

Check the following documentation for all the examples on how you can use moment

https://momentjs.com/docs/#/displaying/as-javascript-date/