I have a table called Events and these are example of EndDate
columns:
I am trying to extract months from these events, but I want them to be like: 11, 12, 1
(11 and 12 from current year, and 1 is from next year - 2013).
var ev = db.Events.Select(d => new { Month = d.StartDate.Value.Month,
EndDate = d.EndDate })
.Where(d => (d.EndDate >= DateTime.Now
|| ( d.EndDate.Value.Day == DateTime.Now.Day
&& d.EndDate.Value.Month >= DateTime.Now.Month) ))
.OrderBy(d => d.EndDate.Value.Year)
.Select(d => new { Month = d.Month }).Distinct();
Well, I don't understand why this query does not work. It extracts months as: 1, 11, 12
which of course, is not what I want...
Ps: You can ignore where
clause, that is only filtering the events from now on
.