I have a report and a datasource where one of the columns are of type TimeSpan. The TimeSpan value appears to display correctly in the report when I use Fields!TheTime.Value
, no problem there.
But I would like to do a Sum on those values to get the total time of a group. In C# and such I can of course do a TimeSpan + another TimeSpan, so I know they can be added. I tried
=Sum(Fields!TheTime.Value)
But it ends up printing out as a long number of some sort. For example for the outputted times above, I would get 457800000000
as the sum. And what is that even supposed to be?
Anyways, how can I sum timespan values in a report? For the above timespans I would like to end up with 12:43:00
as the sum. Unless my head failed me at math once again... but you get the idea :p
sigh The solution annoyingly simple... Why couldn't I just have tried that in the first place? Oh well... maybe because I didn't realise I had access to TimeSpan
class... maybe because I had thought myself blind... But anyways, here it is:
=TimeSpan.FromTicks(Sum(Fields!TheTime.Value))
D'oh!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With