嘿,我遇到了这行代码的问题
db.eventrecords.find({ timestamp: { $gte:ISODate("2013-11-19T14:00:00Z"),
$lt: ISODate("2018-11-19T20:00:00Z") } })
即使我知道那里有数据,此查询和使用时间戳的任何类似查询都不会返回任何内容。
以下是使用d.eventrecords.find()
返回的数据的示例 { "_id" : ObjectId("5a0c9e22da6e704174881b6c"), "userId" :
"59e0265c387d7d22a4f81533", "timestamp" : "Wed Nov 15 2017 15:05:54 GMT-
0500 (Eastern Standard Time)", "name" : "LOGIN" }
有人能说清楚为什么这个查询不会返回数据吗?
答案 0 :(得分:1)
您无法这样做,因为您将日期存储为字符串(而不是时间戳)。