I have tried querying MongoDB through python and get all the objects that were created at a specific date. All the dates in ongare in ISODate format. So they are something like: ISODate("2016-04-19T16:00:00Z")
.
I want to find all the documents that have as a date, the date "2016-03-19" without considering the time. So what I have done in python is:
date = datetime.datetime(2016,03,19)
startTime = date+datetime.timedelta(seconds=1) //this is: 2016-03-19T00:00:01
endTime = (date + datetime.timedelta(days=1)-datetime.timedelta(seconds=1)) //this is 2016-03-19T23:59:59
cursor= db.collection.find({'data.when.value':'$gte':startTime,'$lte':endTime}}])
I get zero results though, although I have data with this date in my database. Can you please tell me what I'm doing wrong? How can you query just by date and get all documents for this date? I have searched a lot but nothing is working for me.