Skip to content

Instantly share code, notes, and snippets.

@smoak
Forked from TheDahv/gist:1946234
Created March 1, 2012 00:49
Show Gist options
  • Save smoak/1946279 to your computer and use it in GitHub Desktop.
Save smoak/1946279 to your computer and use it in GitHub Desktop.
var groupedByWeek = new List<DateTime> {
new DateTime(2012, 02, 01),
new DateTime(2012, 02, 02),
new DateTime(2012, 02, 06),
new DateTime(2012, 02, 13)
}.
GroupBy(s => s.DayOfYear / 7).
.Select(s => new {Date=s.First(), Amount=s.Count()})
.ToDictionary(s => s.Date, s => s.Amount);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment