GeekedOut
GeekedOut

Reputation: 17185

MongoDB - querying for date range always returns the same number

I have this query:

db.users.count(  { confirmed_at : { $gt: start  } } , { confirmed_at : { $lt:  end  } }  ); 
3750

no matter what I set date to:

var end = new Date(2011, 1, 12);

The query returns the same number as a result.

Why would that happen? Am I doing something wrong?

Upvotes: 1

Views: 288

Answers (1)

thomas
thomas

Reputation: 2578

I think you need to concat the two conditions like

db.users.count({confirmed_at: {$gte: start, $lt: end}})

to gain the range query. But this is in theory, had no chance to test this so far! Give it a try!

Upvotes: 2

Related Questions