C# .NET - how to get the data using groupby in sqlserver

Asked By vamsi krishna on 12-Apr-13 05:34 AM
12:01:00
18:32:00
12:30:00
-----------
43:03:00 --------> Total Sum like it


in sql or .net
Sathish S replied to vamsi krishna on 12-Apr-13 06:12 AM
In c#, one way is sum up the time span object.

ex.
var totalSpan = new TimeSpan(myCollection.Sum(r => r.TheDuration.Ticks));
myCollection is can be a list of timespan.

creating timespan instance
// Use TimeSpan constructor to specify:
	// ... Days, hours, minutes, seconds, milliseconds.
	// ... The TimeSpan returned has those values.
	TimeSpan span = new TimeSpan(1, 2, 0, 30, 0);