Search code examples
reporting-servicesssrs-2008ssrs-2012ssrs-2016

SSRS 2016 Sum time values represented as string


I have a column, showing time (hours (may be > 24) : minutes : seconds) which is represented as string in my dataset.

40:02:20
365:23:30
12:00:59
23:59:59

I need to get the sum, which in this case would be:

574:59:59 or 24.3:59:59 (any of this output is ok)

I tried to use the expression below, but it gives me the error, because I need to cast the time value somehow.

=TimeSpan.FromTicks(Sum(Fields!time.Value))

I'd appreciate any help.


Solution

  • It doesn't answer your question specifically but best practice is to store duration in seconds or StartDates and EndDates as a DATETIME or similar, DATATYPE and then use DATEDIFF to calculate duration.

    Then in the SSRS report you can use this expression to display as HH:MM:SS

    =Floor(Sum(Fields!someSeconds.Value) / 3600) & ":" & Format(DateAdd("s", Sum(Fields!someSeconds.Value), "00:00"), "mm:ss")