title: Find between dates into mongo with string type data
body: <p>I have My data Stored like this on mongodb:</p>
  
  <pre><code>{ 
      "_id" : { "$oid" : "5385a437084ea4734b03374f" },
      "linea" : 1, 
      "egunak" : [ 
          { 
              "fetxa" : "2014/05/26", 
              "turnoak" : [ 
                   { 
                       "turno" : 1,
                       "ordenes" : [ 
                           { "ref" : "3CI00001" },
                           { "of" : "OF000d013" }
                       ]
                   }, 
                   { 
                       "turno" : 2, 
                       "ordenes" : [ 
                           { "ref" : "3CI00001" }, 
                           { "of" : "112-2233" }, 
                           { "ref" : "3CI0-0001" },
                           { "ref" : "666" }, 
                           { "ref" : "33" }, 
                           { "ref" : "3355" },
                           { "ref" : "345" },
                           { "ref" : "1234" } 
                       ] 
                   },
                   { 
                       "turno" : 3,
                       "ordenes" : [
                           { "ref" : "3CI00001" },
                           { "ref" : "12" }
                       ]
                   }
              ]
          }, 
          { "fetxa" : "2014/05/27" },
          {
              "fetxa" : "2014/05/28",
              "turnoak" : [
                  { 
                      "turno" : 1,
                      "ordenes" : [
                          { "ref" : "3CI0-0001" },
                          { "of" : "OF200013" }
                      ]
                  },
                  { 
                      "turno" : 2,
                      "ordenes" : [
                          { "ref" : "3CI00001-" },
                          { "of" : "OF232233" },
                          { "of" : "OF289977" }
                      ]
                  },
                  { 
                      "turno" : 3,
                      "ordenes" : [
                          { "ref" : "3CI00001" },
                          { "of" : "OF200-000" },
                          { "ref" : "3CI00001" },
                          { "of" : "OF200000" },
                          { "ref" : "3CI00001" }
                      ]
                  }
              ]
          }, 
          { "fetxa" : "2014/05/29" },
          { "fetxa" : "2014/05/30" },
          { "fetxa" : "2014/05/31" },
          { "fetxa" : "2014/06/01" }
      ]
  },
  { 
      "_id" : { "$oid" : "5385a448084ea4734b033750" },
      "linea" : 2,
      "egunak" : [
          {
              "fetxa" : "2014/05/26",
              "turnoak" : [
                  { 
                      "turno" : 2,
                      "ordenes" : { "ref" : "123" } 
                  }
              ]
          },
          {
              "fetxa" : "2014/05/27",
              "turnoak" : [
                  {
                      "turno" : 1,
                      "ordenes" : [
                          { "ref" : "3CI00002" },
                          { "of" : "2OF000013" }
                      ]
                  },
                  { 
                      "turno" : 2,
                      "ordenes" : [
                          { "ref" : "3CI00001" },
                          { "of" : "2OF2233" },
                          { "ref" : "3CI00001" },
                          { "ref" : "999" }
                      ]
                  },
                  {
                      "turno" : 3,
                      "ordenes" : [
                          { "ref" : "3CI00001" }
                      ]
                  }
              ]
          },
          { 
              "fetxa" : "2014/05/28",
              "turnoak" : [
                  {
                      "turno" : "2",
                      "ordenes" : { "ref" : "66" }
                  }
              ]
          },
          {
              "fetxa" : "2014/05/29",
              "turnoak" : [
                  { 
                      "turno" : 1,
                      "ordenes" : [
                          { "ref" : "3CI00001" },
                          { "of" : "2OF200013" }
                      ]
                  },
                  { 
                      "turno" : 2,
                      "ordenes" : [
                          { "ref" : "3CI00001" },
                          { "of" : "2OF232233" },
                          { "ref" : "3CI00001" }
                      ]
                  },
                  { 
                      "turno" : 3,
                      "ordenes" : [
                          { "ref" : "3CI00001" },
                          { "of" : "2OF200000" },
                          { "ref" : "3CI00001" },
                          { "of" : "2OF200000" }, 
                          { "ref" : "3CI00001" }
                      ]
                  }
              ]
          },
          { "fetxa" : "2014/05/30" },
          { "fetxa" : "2014/05/31" },
          { "fetxa" : "2014/06/01" }
      ]
  }
  </code></pre>
  
  <p>Now I want to find into my data between two dates but the data is stored with in string, how can I achieve that? or I need to store my data on date format?</p>
  
  <p>This is my persist function on nodejs:</p>
  
  <pre><code>exports.save = function(req, res){
      db.open(function(err, db) {
          if(!err) {
              var data = req.body;
              var BSON = mongo.BSONPure;
              var o_id = new BSON.ObjectID(data._id);
  
              db.collection('test').update({'_id': o_id}, { $set :{ egunak: data.egunak } }, {safe:true, multi:false, upsert:false}, function(e, result){
                  if (e) console.log(e)
                  res.send((result===1)?{msg:'success'}:{msg:'error'})
              })
  
          } else {
              onErr(err, function(){
                  console.log(err);
              });
          }
      });
  };
  </code></pre>
  
  <p>Where the $set value is my JSON. How can I store the date data?</p>