Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoVue date search adds 1 to month

Okay I am pretty sure this thing must be a bug... I have to enter the month previous to what I am looking for:

{
   "SportId":"Horse Racing",
   "Date":{$gt: new Date(2012,11,4)}
}

Explain output:

[ 15:21:39 ]
db.Fixture.find({ "SportId" : "Horse Racing", "Date" : { "$gt" : ISODate("2012-12-04T00:00:00Z") } }).limit(50);
db.Fixture.find({ "SportId" : "Horse Racing", "Date" : { "$gt" : ISODate("2012-12-04T00:00:00Z") } }).limit(50).explain();

Can anyone explain this - better than above? Not essential as now that I know I can work around it. But it seems like a pretty strange thing to happen.

like image 943
Matt Canty Avatar asked Dec 07 '12 15:12

Matt Canty


1 Answers

The month is Zero based in the javascript Date constructor.

http://www.w3schools.com/js/js_obj_date.asp

http://www.w3schools.com/jsref/jsref_setmonth.asp

like image 88
sambomartin Avatar answered Oct 22 '22 20:10

sambomartin