I’m trying to perform a range query for a collection of tweets in a mongo database. For some reason the following query will work:
db.posts.find({'created_at': {$gte:"Fri Nov 25 00:00:00 +0000 2011", $lt:"Fri Nov 25 23:59:59 +0000 2011"}})
But the following will not:
db.posts.find({'created_at': {$gte:"Thu Nov 24 00:00:00 +0000 2011", $lt:"Fri Nov 25 23:59:59 +0000 2011"}})
I’m entering the tweet as a JSON object directly into the database, so this shouldn’t be an issue, correct?
You need to make sure you are using real Date values, not strings. For example:
Besides making sure your queries are using real Date values, make sure your stored data contains real Date values also.