DATEDIFF in linq (in months)

entity-framework linq linq-to-entities

Question

select col1,col2,col3 from table1 
where(DATEDIFF(mm, tblAccount.[State Change Date], GETDATE()) <= 4

I want to convert this sql query to LINQ. but I dont know any DateDiff alternative in LINQ. can you please suggest me?

1
12
6/29/2012 10:27:47 AM

Popular Answer

You're looking for SqlMethods.DateDiffMonth.

EDIT: In EF4, use SqlFunctions.DateDiff.

13
4/1/2011 5:50:08 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow