title: Comparing Dates Only on DateTime/DateTimeOffset Objects
body: <p>I receive a DateTime from the client: <code>DateTime CurrentTimeOnClient</code><br>
  I have a DateTimeOffset I get from the db: <code>DateTimeOffset DateTimeOffsetFromDb</code></p>
  
  <p><strong>I need to compare the two dates, IGNORING the time AND time zone.</strong> In other words, I just want the raw date from both objects. I tried using <code>FooDateTimeOffset.DateTime.Date</code> but it seems to still factor in the time, so what I have now is this:</p>
  
  <pre><code>DateTimeOffset clientDateTimeOffSet = DateTime.SpecifyKind(CurrentTimeOnClient, DateTimeKind.Utc);
  clientDateTimeOffSet = await RemoveTimeComponentFromDateTimeOffset(clientDateTimeOffSet);
  clientDateTimeOffSet = await SetTimeZoneOffsetToZero(clientDateTimeOffSet);
  </code></pre>
  
  <p>And the helper methods:</p>
  
  <pre><code>public async Task&lt;DateTimeOffset&gt; SetTimeZoneOffsetToZero(DateTimeOffset dateTimeOffSetObj)
  {
      TimeSpan zeroOffsetTimeSpan = new TimeSpan(0, 0, 0, 0, 0);
      return dateTimeOffSetObj.ToOffset(zeroOffsetTimeSpan);
  }
  
  public async Task&lt;DateTimeOffset&gt; RemoveTimeComponentFromDateTimeOffset(DateTimeOffset dateTimeOffSetObj)
  {
      DateTime dateWithZeroedTime = new DateTime(dateTimeOffSetObj.Year, dateTimeOffSetObj.Month, dateTimeOffSetObj.Day, 0, 0, 0);
      return dateWithZeroedTime; 
  }
  </code></pre>
  
  <p>Then I clean the DateTimeOffset obj from the db in the same way (though obviously without the need to convert them) and compare them. </p>
  
  <pre><code>bool foo = dateFromDb &gt; dateFromClient;
  </code></pre>
  
  <p>P.S. I am aware that these questions HAVE been answered separately, but I would like to see if I made any glaring mistakes or if I am overdoing it. (but again, the suggested <code>.Date</code> solution doesn't seem to work).</p>
  
  <p>Edit: @James</p>
  
  <pre><code>    //TESTING
      var testDateAndTime = new DateTimeOffset(2008, 5, 1, 8, 6, 32,new TimeSpan(1, 0, 0));
      //This is just some db object that has a date field that I had on hand
      var anncmnt = db.Announcements.First(a =&gt; a.Id == 13);
  
      //CLEAN TIME AND DATE
      testDateAndTime = testDateAndTime.DateTime.Date; 
  
      anncmnt.EndDate = testDateAndTime;
      await db.SaveChangesAsync(); 
      //TESTING
  </code></pre>
  
  <p>Db Result: <code>2008-05-01 00:00:00.0000000 -04:00</code></p>