new Date() In MongoDB Query

        <queryString language="MongoDbQuery">
            <![CDATA[{ collectionName: 'orders',
                  findQuery : { customer: 12834,
                      _id: { '$gte': ObjectId(Math.floor((new Date() - (1000*60*60*24*1) / 1000).toString(16) + "0000000000000000")  }
                   sort: { attr.order_No: -1 }

Whats the correct usage for that? Why is the documentation so whack?

Can anybody provide information on the Date object usage or how to get Documents within the past N days ?

d.wendler's picture
Joined: Jun 21 2013 - 7:23am
Last seen: 9 years 5 months ago

2 Answers:


Here is a link to a page detailing how to perform a date range search on documents: 

Please note, that while Jaspersoft is allowing and enabling a connection to MongoDB, the query language documentation and support are provided by MongoDB.



abroitman's picture
Joined: Aug 19 2013 - 12:25pm
Last seen: 8 years 10 months ago

The documentation for the MongoDB query language is here: remember that you need to use Strict JSON since that is what the Mongo Java driver is expecting.

There is also a wiki article that talks about using Date Parameters in MongoDB Queries

marianol's picture
Joined: Sep 13 2011 - 8:04am
Last seen: 4 years 4 months ago