I just tested the following query against your data sample and it worked perfectly:
db.datecol.find(
{
"date":
{
$gte: new Date((new Date().getTime() - (15 * 24 * 60 * 60 * 1000)))
}
}
).sort({ "date": -1 })
More Related Contents:
- Random record from MongoDB
- Find in Double Nested Array MongoDB
- MongoDB: upsert sub-document
- Add new field to every document in a MongoDB collection
- Check that Field Exists with MongoDB
- Find MongoDB records where array field is not empty
- How do I update Array Elements matching criteria in a MongoDB document?
- Get a count of total documents with MongoDB when using limit
- ‘Failed to unlink socket file” error in MongoDB 3.0
- To what level does MongoDB lock on writes? (or: what does it mean by “per connection”
- Mongo order by length of array
- Best practice to maintain a mgo session
- MongoDB group by array inner-elements
- Exception: can’t convert from BSON type EOO to Date
- Delete everything in a MongoDB database
- Mongodb Aggregation Framework: Does $group use index?
- mongodb.conf bind_ip = 127.0.0.1 does not work but 0.0.0.0 works
- How to use Elasticsearch with MongoDB?
- Meteor: difference between names for collections, variables, publications, and subscriptions?
- MongoDB – how to query for a nested item inside a collection?
- Get BinData UUID from Mongo as string
- Get n-th element of an array in MongoDB
- What’s the fastest way to copy a collection within the same database?
- Mongoose: deep population (populate a populated field)
- Getting a distinct aggregation of an array field across indexes
- How to get back the new value after an update in a embedded array?
- How to check if an array field contains a unique value or another array in MongoDB?
- MongoDB index/RAM relationship
- MongoDB Single Document size limit is 16MB
- mongodb aggregate query isn’t returning proper sum on using $sum