0

$gte: ISODate("2010-04-29T00:00:00.000Z"),$lt: ISODate("2010-05-01T00:00:00.000Z")

R. Richards
  • 24,603
  • 10
  • 64
  • 64

1 Answers1

0

You may get the day of the week by calling .getDay() on the date object. Once you have the day of the week, rest are arithmetic operations.

To convert Date to ISODateFormat you can use toISOString

    var dateForCalculation = new Date();
    var prevSunday = new Date(dateForCalculation.setDate(dateForCalculation.getDate()-dateForCalculation.getDay())).toISOString();
    var nextSunday = new Date(dateForCalculation.setDate(dateForCalculation.getDate()+7)).toISOString();

    console.log(prevSunday);
    console.log(nextSunday);
Ramesh
  • 13,043
  • 3
  • 52
  • 88