I have a list of datetime values and i need to group them into hours base. something like
how to categorise the given set of datetime in C#
66 Views Asked by RanjitRock At
2
There are 2 best solutions below
4

You can use linq:
var times = new List<DateTime>();
var groups = times.GroupBy(date => (baseTime - date).TotalHours);
foreach (var @group in groups)
{
Debug.WriteLine("hours: " + group.Key);
foreach (var dateTime in group)
{
Debug.WriteLine(dateTime);
}
}
baseTime
is the time from where you want to start off
You can convert Your time formats in 100 conversion
Possible Result : Aug 27 2013 6:13PM Use string manipulation like substring to retrieve the number 6 and PM
Do some Logic to sort the retrieve Data.
after that your problem is done, Hope this Helps Thanks.