Linq: Difference between 2 DateTimes in TimeSpan
c#, linq, linq-to-entities
Solution
You would want to use SqlFunctions.DateDiff
Tickets.Where(t =>
SqlFunctions.DateDiff("second", t.Date, myTicket.Date) < 120));
Problem
I'm trying to do this: ``` Tickets.Where(t => (t.Date - myTicket.Date) < TimeSpan.FromSeconds(120)); ``` I'm getting the "DbArithmeticExpression arguments must have a numeric common type" error. How can I do this, considering that I need the difference in a TimeSpan? Thanks in advance.