title: How do write a date range query in mongodb using reactive mongo in scala
body: <p>My session collection in database looks like </p>
  
  <pre><code>{ "_id" : ObjectId("545afeb0fb8af1531e70e762"), "sId" : "g38699im4g9fz6ri6pqd31odc0fzy6", "appId" : "c6s3ki1hgay9ntavyt8mxi54ukcfci", "events" : [ { "eType" : "untimed", "name" : "testing", "sId" : "g38699im4g9fz6ri6pqd31odc0fzy6", "st" : ISODate("2014-11-06T04:51:04Z"), "et" : ISODate("2014-11-06T04:52:44Z"), "screen" : "dummy", "data" : "{\"item\":\"immortals of meluha\",\"qty\":\"2\"}" }, { "eType" : "untimed", "name" : "testing", "sId" : "g38699im4g9fz6ri6pqd31odc0fzy6", "st" : ISODate("2014-11-06T04:51:04Z"), "et" : ISODate("2014-11-06T04:52:44Z"), "screen" : "dummy", "data" : "{\"item\":\"immortals of meluha\",\"qty\":\"2\"}" } ], "device" : { "model" : "", "mem" : "", "screen" : { "size" : "", "density" : "", "aspect" : "" } }, "network" : { "career" : "", "nType" : "" }, "location" : { "lat" : "", "long" : "" }, "user" : { "uId" : "ewkrmwyaidx5avo2adj7nh839mrzdc", "data" : "{}" }, "competetors" : [ ], "st" : ISODate("2014-11-06T04:51:04Z"), "duration" : -1, "tData" : [ ] }
  </code></pre>
  
  <p>I am trying to get the Sessions that lie between a date range. 
  When I do something like </p>
  
  <pre><code>val query = BSONDocument("st" -&gt; BSONDocument("$gt" -&gt; BSONDateTime(1415229720*1000L) )  )
  collection.find(query).cursor[BSONDocument].enumerate().apply(Iteratee.foreach { doc =&gt; println("found document: " + BSONDocument.pretty(doc)) })
  </code></pre>
  
  <p>It gives me all the sessions in the database while there are only 5 sessions greater than the given epoch. </p>
  
  <p>I tried doing this too</p>
  
  <pre><code>val query = BSONDocument("st" -&gt; BSONDocument("$gte" -&gt; BSONDateTime(1415228760*1000L)).add( BSONDocument("$lte" -&gt; BSONDateTime(1415229720*1000L) ) ) )
  </code></pre>
  
  <p>But it didn't work.</p>
  
  <p>What is the correct way to query session class having "st" between two timestamps ?</p>