Reputation: 1451
I have a list of datetime values and i need to group them into hours base. something like
Upvotes: 0
Views: 56
Reputation: 20764
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
Upvotes: 1
Reputation: 1722
You can convert Your time formats in 100 conversion
select convert(varchar, GetDate(), 100) as '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.
Upvotes: 0