我想得到一个比另一个Date对象晚30分钟的Date对象.我如何使用JavaScript?
我有一个查询,我需要获取特定日期之前或之后一天的事件.我需要在该ISODate变量中添加或减去一天.这是我的查询:
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);
});
});
Run Code Online (Sandbox Code Playgroud)
如何在mongodb shell中添加或减去ISODate变量的天数?