I've following documents in my mongodb collection:
     {
       "_id": ObjectId("579493bccdba841a0bf5ad1a"),
       "uniqueId": "bUbOaciS1g",
       "chat": [
         {
           "TS": ISODate("2016-07-24T10:09:00.631Z"),
           "user_ques": "hi",
           "rep_ans": "hello" 
        },
         {
           "TS": ISODate("2016-08-01T10:09:40.814Z"),
           "user_ques": "how are you?",
           "rep_ans": "i am fine"
        },
         {
           "TS": ISODate("2016-08-04T10:09:55.724Z"),
           "user_ques": "help me",
           "rep_ans": "sure"
        }
]
    }
    {
       "_id": ObjectId("579493bccdba841a0bf5ad1b"),
       "uniqueId": "xyzOaciS1g",
       "chat": [
         {
           "TS": ISODate("2016-08-09T10:09:00.631Z"),
           "user_ques": "hi",
           "rep_ans": "hello" 
        }
]
    }
what i want to do is get only fields with the specific dates and exclude others. query i tried:
db.collection.find({'chat.TS':{$gte:ISODate("2016-08-01T00:00:00.000Z"),$lte:ISODate("2016-08-10T00:00:00.000Z")}}).pretty()
result i expected:
{
       "TS": ISODate("2016-08-01T10:09:40.814Z"),
       "user_ques": "how are you?",
       "rep_ans": "i am fine"
    },
     {
       "TS": ISODate("2016-08-04T10:09:55.724Z"),
       "user_ques": "help me",
       "rep_ans": "sure"
    }
    {
       "TS": ISODate("2016-08-09T10:09:00.631Z"),
       "user_ques": "hi",
       "rep_ans": "hello" 
    }
instead what i got is expected result plus the field with date 2016-07-24. I wanted to get only result between the specified date. I'm new to mongo. How do I get the expected result?
MongoDB shell version: 2.4.9
Edit
solution provided by Prabhu and Ihor work fine for mongodb client, but I'm not able to translate the same query for pymongo. Can somebody help me with that.
 
     
     
     
     
    