MongoDB : Querying collection within a Date Range -
i have collection in mongodb records in format
db.userlogins.find().pretty() { "_id" : objectid("519bb8c11f30bbf5bcba06f0"), "userid" : "sai", "created_at" : "2013-05-16 10:31:02.765" } { "_id" : objectid("519bb8cf1f30bbf5bcba06f1"), "userid" : "sai", "created_at" : "2013-05-17 10:31:02.765" } { "_id" : objectid("519bb8db1f30bbf5bcba06f2"), "userid" : "sai", "created_at" : "2013-05-18 10:31:02.765" } { "_id" : objectid("519bb8e71f30bbf5bcba06f3"), "userid" : "sai", "created_at" : "2013-05-19 10:31:02.765" } { "_id" : objectid("519bb8f21f30bbf5bcba06f4"), "userid" : "sai", "created_at" : "2013-05-20 10:31:02.765" } { "_id" : objectid("519bb8fc1f30bbf5bcba06f5"), "userid" : "sai", "created_at" : "2013-05-21 10:31:02.765"
i trying find out users logged in in certian range
so tried
db.userlogins.find({created_on: {$gte: "2013-05-17 10:31:02.765", $lt: "2013-05-21 10:31:02.765"}});
but dont know why not returuning data ?? please
this work:
db.userlogins.find({created_at: {$gte: "2013-05-17 10:31:02.765", $lt: "2013-05-21 10:31:02.765"}});
Comments
Post a Comment