I m trying to query my collection by a range of date. I m trying to use ISODate in the query passing a javascript date and it doesn't work, and I dont know why...
I have tried :
db.collection.aggregate {date: {$gt: 'new Date(' + start.toISOString() + ')', $lt: 'new Date(' + end.toISOString() + ')'}}, {"$group": {_id: "$user", count: {$sum: 1}}}
db.collection.aggregate {date: {$gt: 'ISODate(' + start.toISOString() + ')', $lt: 'ISODate(' + end.toISOString() + ')'}}, {"$group": {_id: "$user", count: {$sum: 1}}}
db.collection.aggregate {date: {$gt: 'ISODate(' + start + ')', $lt: 'ISODate(' + end + ')'}}, {"$group": {_id: "$user", count: {$sum: 1}}}
db.collection.aggregate {date: {$gt:start, $lt: end}}, {"$group": {_id: "$user", count: {$sum: 1}}}
Nothing works...
Can you help me ? Or explain me why it doesn't work in each case ?