0

I have inserted time in mongodb collection in this format, "09:68". Now I want to write a find query using time and unable to write on. Can anyone tell me any solution without modifying my database?

Data Format is below,

"dep_timing":[{"time": "09:50"}, 
 {"time": "11:50"},
 {"time": "12:50"},
 {"time": "13:50"},
 {"time": "14:50"},
 {"time": "15:50"},
 {"time": "16:50"},
 {"time": "17:50"},
 {"time": "18:50"},
 {"time": "19:50"}, 
 {"time": "20:50"},
 {"time": "21:50"},
 {"time": "22:55"}],

Tested Queries:

>db.east.find({"dep.dep_timing.time":{$gte:05}});
>db.east.find({"dep.dep_timing.time":{$gte:10}});

Thanks,

2 Answers2

0

Check this SO link Find between two dates in MongoDB. You need to provide the date format in a way which MongoDB understands.

Community
  • 1
  • 1
Arka Ghosh
  • 845
  • 1
  • 11
  • 23
0

I tried below query and it is working fine.

>db.east.find({"dep.dep_timing.time":{$gte:"05:10"}});