Query MongoDb for a datetime value less than NOW Query MongoDb for a datetime value less than NOW mongodb mongodb

Query MongoDb for a datetime value less than NOW


Use the Javascript function new Date():

db.collection.find({ Expiration: { $lte: new Date() } })

The Mongo shell is just a Javascript shell, so you can, in principle, use any Javascript method.


You can use any javascript function in query of mongo.

Try this :

db.collection.find({"Expiration":{"$lte": new Date()}})