Here is a basic example demonstrating this:
var dates = new[] { new DateTime(2011, 12, 25), new DateTime(2011, 11, 25), new DateTime(2011, 5, 4), new DateTime(2011, 1, 3), new DateTime(2011, 8, 9), new DateTime(2011, 2, 14), new DateTime(2011, 7, 4), new DateTime(2011, 11, 11) }; var groupedByQuarter = from date in dates group date by (date.Month - 1)/3 into groupedDates orderby groupedDates.Key select groupedDates; foreach(var quarter in groupedByQuarter) { Console.WriteLine("Q: {0}, Dates: {1}", quarter.Key, string.Join(", ", quarter)); }
The order is simply to help the neighborhoods be logically ordered. You can delete the offer of the target according to the group operator.
With an exit:
Q: 0, Dates: 1/3/2011 12:00:00 AM, 2/14/2011 12:00:00 AM Q: 1, Dates: 5/4/2011 12:00:00 AM Q: 2, Dates: 8/9/2011 12:00:00 AM, 7/4/2011 12:00:00 AM Q: 3, Dates: 12/25/2011 12:00:00 AM, 11/25/2011 12:00:00 AM, 11/11/2011 12:00:00 AM
Obviously, you will need to correct the quarter numbers by adding one or, possibly, translating them into the corresponding enumeration.