在mongodb集合中,我有一个变量DateTimeAsString,其值为04-26-2017 11:51:40:445。
当我尝试执行这样的事情时
db.getCollection('collection').find({dateTimeAsString: { "$gte": ISODate("2018-03-05"),"$lte": ISODate("2018-03-06") }})
它返回0个文件。
我尝试使用$ where运算符并将DateTimeAsString转换为Date,但它仍然返回0个文档。
db.getCollection('collection').find({$where : function() {
var date = new Date(this.dateTimeAsString)
var newdate=new Date("2018-03-05 00:00:00");
if (date > newdate)
return this
}}).count()
注意 - 我想在Robo3t控制台中使用它。
感谢。