title: Add a Date in Linq to Entities
body: <p>With Linq to Entities, I am trying to query a Log table to find rows near a matching row. I am having trouble with adding a date inside the query. This is what I have so far.</p>
  
  <pre><code>from
      l in objectSet.Logs
  let
      match = objectSet.Logs.Where(whatever).FirstOrDefault()
  where
         l.Timestamp &gt; (match.Timestamp - twoHours)
      &amp;&amp; l.Timestamp &lt; (match.Timestamp + twoHours)
  select
      l
  </code></pre>
  
  <p>Leaving out the "whatever" condition that finds the row I'm interested in, "twoHours" has variably been a time span, a <code>.AddHours()</code> function and so forth. I haven't found the right way that EF can generate SQL that adds the value from a field (match.Timestamp) to a constant.</p>
  
  <p>The obvious solution is to do the "match" query first and then use the literal value in a second query, but I have simplified the code example here to the main problem (adding dates in the query) and in actual fact my query is more complex and this would not be ideal.</p>
  
  <p>Cheers</p>