I have a order list and want to group them by the created date.
Each order's created datetime will be like "2010-03-13 11:17:16.000"
How can I make them only group by date like "2010-03-13"?
var items = orderList.GroupBy(t => t.DateCreated)
.Select(g => new Order()
{
DateCreated = g.Key
})
.OrderByDescending(x => x.OrderID).ToList();
Update: How can I group order by month? And the following code is not correct.
var items = orderList.GroupBy(t => t.DateCreated.Month)
.Select(g => new Order()
{
DateCreated = g.Key
})
.OrderByDescending(x => x.OrderID).ToList();
Many thanks.