title: Convert string to ISODate in MongoDB
body: <p>I am new to MongoDB and I am stuck on the String to Date conversion. In the db the date item is stored in String type as <code>"date":"2015-06-16T17:50:30.081Z"</code></p>
  
  <p>I want to group the docs by date and calculate the sum of each day so I have to extract year, month and day from the date string and wipe off the hrs, mins and seconds. I have tried multiple way but they either return a date type of 1970-01-01 or the current date.</p>
  
  <p>Moreover, I want to convert the following mongo query into python code, which get me the same problem, I am not able to call a javascript function in python, and the <code>datetime</code> can not parse the mongo syntax <code>$date</code> either.</p>
  
  <p>I have tried:</p>
  
  <pre><code>new Date("2015-06-16T17:50:30.081Z")
  new Date(Date.parse("2015-06-16T17:50:30.081Z"))
  etc...
  </code></pre>
  
  <p>I am perfectly find if the string is given in Javascript or in Python, I know more than one way to parse it. However I have no idea about how to do it in MongoDB query.</p>
  
  <pre><code>  db.collection.aggregate([
                      {
                          //somthing
                      },
                      { 
                          '$group':{
                              '_id':{ 
                                  'month':  (new Date(Date.parse('$approTime'))).getMonth(), 
                                  'day': (new Date(Date.parse('$approTime'))).getDate(), 
                                  'year':  (new Date(Date.parse('$approTime'))).getFullYear(),
                                  'countries':'$countries'
                              },
                               'count': {'$sum':1}
  
                      }
                  }
  ])
  </code></pre>