Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tMongoDBInput query for date gte

I have some documents in MongoDB that has a DateTime field
{"Name" : "a name", "InsertDate" : ISODate("2014-01-23T14:32:11.746Z")}
and I want to get all the document with InsertionDate greater than 2014-01-23 00:00:00.
I tried the following queries but doesn't work:
{"InsertDate": {"$gt":ISODate("2014-01-23T00:00:00Z")} (got Error com.mongodb.util.JSONParseException pointing to ISODate)
{"InsertDate": {"$gt":new Date("2014-01-23T00:00:00Z")} (got Error com.mongodb.util.JSONParseException pointing to new Date)
Some one suggested I should use a syntax like: {"InsertDate": {"$gt":{"$date":"2014-01-23T00:00:00Z"}} but does not produce the results I expect (got no Error from Talend but doesn't retrieve any document (probably this syntax is not supported by Mongo)).
Any suggestions on how to include in query?
I am using TOS for BigData and MongoDB 2.2.3.
Labels (3)
2 Replies
Anonymous
Not applicable
Author

Hi,
Please try to replace ISODate("2014-01-23T00:00:00Z")
with
{ "$date": "2014-01-23T00:00:00Z"} to see if it is OK with you.
Here is a on-line related doc for mongodb-extended-json
http://docs.mongodb.org/manual/reference/mongodb-extended-json/
and stackoverflow articles http://stackoverflow.com/questions/19819870/date-query-with-isodate-in-mongodb-doesnt-seem-to-work and http://stackoverflow.com/questions/20561381/mongodb-nodejs-how-to-query-isodate-fields.
Best regards
Sabrina
Anonymous
Not applicable
Author

"{date : { $gte :{\"$date\":\"2019-11-10T00:00:00Z\"}}}"