new { Name = r. UserName, Year = r.SomeDateTime. Year, Month = r.SomeDate..." />

Linq to Sql - DateTime Format - YYYY-MMM (2009-Mar)?

I wonder if you shouldn't do that the "long" way dc. MyTable . GroupBy(r => new { Name = r.

UserName, Year = r.SomeDateTime. Year, Month = r.SomeDateTime. Month }) .

Select(r => new { Name = r. UserName, Year = r. Year, Month = r.

Month, Count = r.Count() }) . OrderBy(r => r. Year) .

ThenBy(r => r. Month) . ThenBy(r => r.Name) If you need the format as a string, do that later at the UI.

Either by reconstructing a DateTime etc, or using CultureInfo.CurrentCulture.DateTimeFormat. GetMonthName(...).

I wonder if you shouldn't do that the "long" way... dc. MyTable . GroupBy(r => new { Name = r.

UserName, Year = r.SomeDateTime. Year, Month = r.SomeDateTime. Month }) .

Select(r => new { Name = r. UserName, Year = r. Year, Month = r.

Month, Count = r.Count() }) . OrderBy(r => r. Year) .

ThenBy(r => r. Month) . ThenBy(r => r.Name); If you need the format as a string, do that later at the UI.

Either by reconstructing a DateTime etc, or using CultureInfo.CurrentCulture.DateTimeFormat. GetMonthName(...).

Not the answer I "wanted" but I think probably the most correct. Thanks for the tip on using DateTimeFormat. GetMonthName(...).

– Chad Mar 10 '09 at 23:25 Curses, foiled again ;) – Jon Skeet Mar 10 '09 at 23:30.

I would avoid turning anything into a string at the database. Group by r.SomeDateTime. Year and r.SomeDateTime.

Month, ordering by year then month then name, select the year and the month separately (along with the count), and then if you need to do the projection to a string format back in the client code. By the way, I suspect your second OrderBy should be a ThenBy - currently the Name is actually the most important thing you're ordering by.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions