I have a query where I need to get events that are one day before or after from a specific date. I need to add or subtract one day to that ISODate variable. Here is my query :
db.event.find().forEach( function (x) {
print("x : " + x.EventID + ", " + x.ISODate);
db.events.find( {
"$or" : [{
"StartDate" : { "$gte" : x.ISODate } // Here i need to subtract one day
}, {
"EndDate": { "$lt" : x.ISODate} // Here i need to add one day
}]
}).forEach(function(otherDay) {
print("x.EventID : " + x.EventID + ", other.Date : " + otherDay.StartDate + " - " + otherDay.EndDate);
});
});
How can i add or subtract days to an ISODate variable in mongodb shell?