title: Best way for storing and querying DateTime in Azure CosmosDB
body: <p>Currently I work on indexing documents in Azure Cosmos DB SQL API. I read here:</p>
  <p><a href="https://docs.microsoft.com/en-us/azure/cosmos-db/working-with-dates" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/cosmos-db/working-with-dates</a></p>
  <p>that date type could be stored as a string or numeric value as Unix timestamp.</p>
  <p>There are several advantages when using string format <code>yyyy-MM-ddTHH:mm:ss.fffffffZ</code> like e.g. human readable, but there is not written directly that this is also more performant when querying.</p>
  <p>So we can use string range index or numeric range index for epoch time.</p>
  <p>Does someone know what is faster for querying - range filters operations?</p>
  <p>e.g. <code>startTime &gt; x and  startTime &lt; y</code></p>
  <p>or in udf in similar way when taking into account only hour
  e.g.</p>
  <pre><code>function somefunc(ts, firstHour, secondHour) {
      var ts_date = new Date(ts);
      var hour = ts_date.getHours();
      return hour &gt;= firstHour &amp;&amp; hour &lt; secondHour;
  }
  </code></pre>