1

I'm very confused and I can't seem to find any explanations on the web. windowStart is a ISODate in my documents.

When using the mongodb-java-driver (via the mongoTemplate in Spring) the following works fine...

{windowStart : {$lt : new Date()}}

When I use MongoDb Compass GUI and type the above in the Filter it is marked as not valid. If I change it to...

{windowStart : {$lt : new Date('2018-10-01')}}

...then it is marked as valid and works

Another example...

{windowStart : {$gt : new Date(new Date('2018-10-01').getTime()+1000*60*60*24*64)}}

Does not work in mongodb-java-driver (via the mongoTemplate in Spring).

Does work in MongoDb Compass GUI

So I just can't work out what I can and cannot do. There is something I'm missing about how the client drivers work and the differences? I see lots of examples on the web for searching date ranges etc yet most don't work for me, so again I'm wondering what client they have been written for

paul
  • 494
  • 6
  • 17

1 Answers1

0

In the below script, you will get data between the given date {windowStart:{$gte:ISODate('2022-12-28'),$lte:ISODate('2022-12-29')}}