I am trying to use the following Aggregate Calculation.
string time = trabajadoresTable.Compute ( "Sum(DateTime)" ,
"") .ToString();
I need to sum the hours in a column with type DateTime.
If they be numbers this work good
"trabajadoresTable.Compute("Sum(pago)", "")"
But with the type DateTime's in a column make me the following error
In the System.Data.DataException was generated the error:
Invalid use of Aggregate Calculation Sum( ) and the type DateTime.
how I sum the hours in one column if it the type is DateTime
Thanks
Marc Gravell - 18 Apr 2008 08:19 GMT
loop and accumalate...
int hours = 0;
foreach(blah row in records)
{
hours += row.DateField.Hour;
}
If you have LINQ you can do it inline:
int hours = records.Sum(row => row.DateField.Hour);
Marc
edcha - 20 Apr 2008 20:55 GMT
I don't have a Linq
Only it can be done for loop and accumalate...
Thanks