title: Selecting data between timestamp range when timestamp is string in MongoDB
body: <p>Document structure looks like following in MongoDB. Timestamp is stored as string in mongo so ISODate doesn't work. How can I select the data between two timestamps in this case.</p>
  <pre><code>    {
       &quot;_id&quot; : NumberLong(5702509046), 
      &quot;totalProduct&quot; : &quot;0.00&quot;, 
      &quot;status&quot; : &quot;COMPLETED&quot;, 
      &quot;dateCreated&quot; : &quot;10/02/2020 11:31:48&quot;, 
      &quot;lastUpdated&quot; : &quot;10/13/2020 15:39:18&quot;
  }
  </code></pre>
  <p>Among the several other things, I tried something like this to convert the string date into date object and then do the comparison but this doesn't take end timestamp into consideration. It returns all documents greater than the input date but doesn't stop at the end date. Need help with straightening this query</p>
  <pre><code>db.getCollection(&quot;MyCollection&quot;).find({&quot;$expr&quot;: {&quot;$gte&quot;: [{ &quot;$dateFromString&quot;: { &quot;dateString&quot;: &quot;$lastUpdated&quot; ,timezone:&quot;America/New_York&quot;}}, new Date(&quot;10/09/2020 10:40:55&quot;) ]},&quot;$expr&quot;: {&quot;$lte&quot;: [{ &quot;$dateFromString&quot;: { &quot;dateString&quot;:&quot;$lastUpdated&quot;,timezone:&quot;America/New_York&quot;}}, new Date(&quot;10/12/202010:14:55&quot;) ]},status:{$in:[&quot;COMPLETED&quot;]}},{&quot;_id&quot;:1, &quot;lastUpdated&quot;:1}).sort({&quot;lastUpdated&quot;:-1});
  </code></pre>