0

I have a table with a column with different smalldatetime value. I would separate results by Month and Year, something like this:

JANUARY 2016: ....

....

AUGUST 2017: ....

SEPTEMBER 2017: ...

...

I have done something like this:

var query = db.Table.GroupBy(q => q.date.Value.Month);

but it separate only by month and not also by Year, so I can't discern for example AUGUST 2016 from AUGUST 2017.

Can someone help me?

Alfra
  • 155
  • 8

1 Answers1

1

This should serve your purpose:

    var groupedDates = dates.GroupBy(d => new { d.Date.Year, d.Date.Month }).SelectMany(g => g.ToList());
Tanjeer
  • 89
  • 4