new Date() In MongoDB Query

Jaspersoft Community 'Read-Only' as of July 8, 2022

Transition to New TIBCO Community Just Weeks Away

You can still search, review wiki content, and review discussions in read-only mode. Please email community@tibco.com with questions or issues requiring TIBCO review or response.

        <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 }
                 }]]>
        </queryString>

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
153
Joined: Jun 21 2013 - 7:23am
Last seen: 8 years 10 months ago

2 Answers:

Hi,

Here is a link to a page detailing how to perform a date range search on documents: http://cookbook.mongodb.org/patterns/date_range/ 

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

Thanks,

Assaf

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

The documentation for the MongoDB query language is here: http://community.jaspersoft.com/wiki/jaspersoft-mongodb-query-language 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
12102
Joined: Sep 13 2011 - 8:04am
Last seen: 3 years 9 months ago
Feedback