title: MongoDB aggregate by date in string format doesn't work
body: <p>I have a mongodb collection with a date field "localHitDate" which is a string property and I'd like to aggregate on this date. So, I have to convert my date string into a BSON date type, but it did not work :</p>
  
  <pre><code>db.log.aggregate([
  { $match:{"category":"log"}},
  { $group: 
      {
      _id:{
          location : "$location",
          year : { $year : ISODate(localHitDate) },        
          month : { $month : ISODate(localHitDate) },        
          day : { $dayOfMonth : ISODate(localHitDate) }
          },
      total: {$sum:1}, 
      payload: {$sum:"$technicalData.payload"}
      }
  },
  { $sort: { total : -1} }
  ])
  </code></pre>
  
  <p>I have this error : ReferenceError: localHitDate is not defined (shell):7</p>
  
  <p>I tried ISODate($localHitDate) but I still have an error.</p>
  
  <p>Do you know how to do this?</p>
  
  <p>Thank you</p>