title: LINQ DB Arithmetic must have common type (Date Comparison
body: <p>I am trying to get the record from a database with the highest amount of days using a start and end date. I keep getting a System.Argument.Exception in the Entity.dll. </p>
  
  <p>The error states:</p>
  
  <pre><code>{"DbArithmeticExpression arguments must have a numeric common type."}
  </code></pre>
  
  <p>Here is my LINQ statement:</p>
  
  <pre><code>var maxDaysTask = whseTasks.Where(x =&gt; x.CompDate != null &amp;&amp; x.TaskDate != null).Max(x =&gt; ((DateTime)x.TaskDate - (DateTime)x.CompDate).TotalDays);
  </code></pre>
  
  <p>The CompDate(end date) and TaskDate(begin date) are both nullable datetimes. Any advice?</p>