0

in mongodb date is stored as ISODate("2015-07-15T03:24:16.271Z"), I want to search the record when user provides 2015-07-15.

I have tried something like this. but it does not working

exports.memberByJoinDate = function(req,res){

      var date = req.params.search;


    var regex = new RegExp(req.params.search, "i"),
        query = {
            created_date: regex
        };

    user.find(query, function(err, members) {

            res.json(members);

    });

};
Manoj Sanjeewa
  • 1,069
  • 1
  • 11
  • 34
  • It's not a "string" it's a [Date()](http://www.w3schools.com/jsref/jsref_obj_date.asp). Also see `$gt` and `;$lt` in [query operators](http://docs.mongodb.org/manual/reference/operator/query-comparison/) – Blakes Seven Jul 15 '15 at 06:28
  • i do not want to find date within a range. not clear how to use $gt and $lt – Manoj Sanjeewa Jul 15 '15 at 06:46
  • 1
    Yes you do. Dates on "one day" fall between "one day" and the "next day". Clear examples in the answers to the linked question. – Blakes Seven Jul 15 '15 at 06:47

0 Answers0