Reputation:
I am working on mongodb.I need to find the object between two dates.I stored date as a time stamp.My sample object is:
{ "_id" : ObjectId("5a166be2509a93571c1546f4"),
"project_id" : "5a1668b6509a93571c154509",
"project_name" : "WORLD AIDS DAY",
"sex" : "MALE",
"title" : "Apply for MTV promo",
"creation_time" : "1511418850391", }
I need to find object between two dates. I have tried using this but still not works:
db.collection.find({creation_time: {
$gte: new Date(1511418850391),
$lte: new Date(1521457316108)
}})
It does not display anything.Where i am doing wrong??
Upvotes: 0
Views: 36
Reputation: 292
Try using
db.collection.find({creation_time: {$gte: "1511418850391",$lte: "1521457316108"}})
Upvotes: 3