How to find objects between two date ranges in mongodb

379 views Asked by At

How to find objects between two date ranges in mongodb

{
"_id" : ObjectId("583b47e6d991392532ec6ac0"),
    "title" : "Title1",
    "description" : "Description1",
    "createdOn" : "10-Nov-2016  02:23 AM"

}

{
"_id" : ObjectId("583b47e6d991392532ec6ac1"),
    "title" : "Title2",
    "description" : "Description2",
    "createdOn" : "15-Nov-2016  02:23 AM"

}

{
"_id" : ObjectId("583b47e6d991392532ec6ac2"),
    "title" : "Title3",
    "description" : "Description3",
    "createdOn" : "28-Nov-2016  02:23 PM"

}

How to find objects between 10-Nov-2016 00:00 AM to 28-Nov-2016 12:59 PM this date range in mongodb

I tried this one but got error

db.tasks.find({created_on: {$gte: ISODate("10-Nov-2016 00:00 AM"),$lt: ISODate("28-Nov-2016 12:59 PM")}})

I am using JAVA and backend as mongoDB Please help me...

My error is this

2016-12-19T21:29:20.823+0530 E QUERY    Error: invalid ISO date
    at Error (<anonymous>)
    at ISODate (src/mongo/shell/types.js:64:15)
    at (shell):1:35 at src/mongo/shell/types.js:64
0

There are 0 answers