Mongodb, time difference between two checkpoints <p>I m actually developping an application using a Mongodb database. Actually, there's a system with "checkpoints", a user scan an NFC tag when he enters in a place, and scan this same tag to leave this place.</p> <p>So, in my database, I have something like :</p> <pre><code>{ "enterDate":"the-date-iso-string-formatted", "leaveDate":"the-date-iso-string-formatted" } </code></pre> <p>Actually, I need to detect what is the time between two different end point. I mean, how much time the user takes to travel from one place, to the next one.</p> <p>In fact it corresponds to the avg of all the </p> <blockquote> <p>endPoint[1].enterDate- endPoint[0].leaveDate</p> </blockquote> <p>What is the best way, or the quickest way to manage this ?</p> <p>Thanks for advance</p>