Search code examples
mongodbisodate

Error using gte projection option with an ISODate object n Mongodb shell


I have a collection with a timestamp field stored in the ISODate format. This database is populated by a third party. A subset of the document looks like:

collection{
    "_id" : "foobar/201310",
    "name" : "SomeName",
    "processedtime" : "2013-10-01T00:00:00.000Z",
    "value" : 375439
       .
       .
       .
}

The data in the processedtime field looks like 2014-10-21T12:13:12.056790

When I query this collection with the following query:

db.collection.find({},{processedtime:{$gte : ISODate("2014-10-21T00:00:00.000Z")}});

I get this error:

Unsupported projection option "$gte", "code":13097";

I get the same error when I change the ISODate in the query to "new Date" or change $gte to $gt

I am using version 2.4.6, Is there some configuration piece or syntax problem with my query? I am also wondering since the data goes out to nano seconds is this a problem? I have looked for this error and no one seems to be reporting it with a query like this.


Solution

  • db.collection.find({},{processedtime:{$gte : ISODate("2014-10-21T00:00:00.000Z")}}); should be db.collection.find({processedtime:{$gte : "2014-10-21T00:00:00.000Z"}});.