title: MongoDB Compass Aggregation: Change string to Time
body: <p>I'm after uploading a dataset to MongoDB with some fields as time. When these were uploaded they went in as strings. Like TOC below:</p>
  
  <pre><code>_id:5dd1a91511a7e24b487bce43 
  Unit:"Fire" 
  Date:"01-Jan-13" 
  TOC:"01:27:19"
  </code></pre>
  
  <p>I am trying to change these using the Aggregations tool in Compass. I have matched all documents where TOC is not a timestamp:</p>
  
  <pre><code>$match
  /**
   * query - The query in MQL.
   */
  {
    TOC: {$not: {$type: 17}}
  }
  </code></pre>
  
  <p>And I am then trying to convert the string to be read as time instead of a string:</p>
  
  <pre><code>$project
  /**
   * specifications - The fields to
   *   include or exclude.
   */
  {
    TOC: {
           "$dateFromString": {
              "dateString": '$TOC',
              "format": "%H:%M:%S"
           }
        }
  }
  </code></pre>
  
  <p>Getting the error:</p>
  
  <pre><code>an incomplete date/time string has been found, with elements missing: "01:27:19"
  </code></pre>
  
  <p>Any idea how I can fix this, or if there is a better way to do it?</p>