Alex Rivera | Logout

DateDiff in LINQ

Asked 2010-07-15T09:54:42.030
9

How I can find datediff in month using LINQ?

Edit
Report

1 Answer

0

If I understand correctly, you want the number of month boundaries crossed between two specific dates. You don't need LINQ for that; this should work:

// Assuming DateTime startDate, endDate
int monthDiff = ((endDate.Year - startDate.Year) * 12) + 
                (endDate.Month - startDate.Month);
answered 2010-07-15T10:26:20.533

Your Answer