title: Entity Framework Core 6 - Date Comparision
body: <p>I need to create a query to find records between a date range. I need to truncate the time for comparison. I came across a few threads suggesting to truncate time using <code>DbFunctions.TruncateTime</code> when comparing the dates.</p>
  <p>I cannot find <code>DbFunctions</code> class in EntityFrameworkCore 6.0. How do I truncate time and compare the DateTime columns?</p>
  <p>Edit: Excerpt from my query handler</p>
  <pre><code>IQueryable&lt;TestReportItem&gt; query = _context.TestReportItems;
  DateTime requestDateStart = DateTimeOffset.FromUnixTimeMilliseconds(request.TestDateStart).LocalDateTime;
  DateTime requestDateEnd = DateTimeOffset.FromUnixTimeMilliseconds(request.TestDateEnd).LocalDateTime;
  
  if (request.FacilityId != 0)
  {
      query = query.Where(e =&gt; e.FacilityId == request.FacilityId);
  }
  
  if (request.TestDateStart != 0 &amp;&amp; request.TestDateEnd != 0)
  {
      query.Where(e =&gt; e.TestDate.Date &gt;= requestDateStart
          &amp;&amp; e.TestDate.Date &lt;= requestDateEnd);
  }
  
  var count = query.Count();
  
  return count;
  </code></pre>
  <p>The request will be for a date range (dates converted into <code>UnixTimeMilliseconds</code>). I am using SqLite database.</p>