I'm having a collection named revisions
and it contains following data,
{
"_id" : NumberLong(1007),
"createdDate" : ISODate("2017-09-25T14:00:53.020Z"),
"name" : "John",
"status" : 700
}
I want to filter data for a given status and date(only date ignore time) range to generate reports. I'm using Jaspersoft studio. I have created two parameters fromDate
and toDate
. I've set up the parameters to parse as java.util.Date
. I'm giving values for these parameters by a datepicker.
Here are some queries that I've tried,
1)
{
"collectionName":"revisions",
"findQuery":{
"status":700,
"createdDate": {"$gte" : $P{fromDate}},
"createdDate": {"$lte" : $P{toDate}}
}
}
2)
{
"collectionName":"revisions",
"findQuery":{ "status": 700, "createdDate": { "$gte": $P{fromDate}, "$lte": $P{toDate} } }
}
3)
{
"collectionName":"revisions",
"findQuery":{
"status" : 700,
$and: [ { "createdDate" : { '$gte' : $P{fromDate}}},
{"createdDate" : { '$lte' : $P{toDate}}} ]
}
}
There are similar questions like this[1] [2], but I couldn't find a solution, maybe something wrong with the way I've used parameters in my query or is there something to do with the ISODate
type.