You could do this with expressions only but this way is a little bit more reusable..
Add the following code to your Report's custom code
(apologies to the original author who's blog I based this on years ago... I can't find your post)
Public Function SecondsAsHHMMSS(ByVal secs) As String
Dim h As String =INT(secs/3600)
Dim m as string
Dim s as string
If Len(h) <2 Then
h = RIGHT(("0" & h), 2)
End If
m = RIGHT("0" & INT((secs MOD 3600)/60), 2)
s = RIGHT("0" & ((secs MOD 3600) MOD 60), 2)
SecondsAsHHMMSS= h & ":" & m & ":" & s
End Function
This function will take a number of seconds and convert to to HH:MM:SS format.
Now all we have to do is pass in the cumulative number of seconds for each row.
We can use System.TimeSpan for this.
This assumes the database field is a TIME datatype
=Code.SecondsAsHHMMSS(RunningValue(Fields!TimeInOffice.Value.TotalSeconds, SUM, Nothing))
Starting from the middle and working out....
- We get the value of the
TimeInOffice
field and, as it's a Time
datatype we can use the TotalSeconds
property to get the number of seconds this time represents.
- We get the running sum of these number of seconds ('Nothing' is the scope, if you want to limit the scope within a rowgroup etc, put the name of the rowgroup, in quotes, in place of the
Nothing
keyword)
- New we have the number of seconds, we pass this to our custom function
The result looks like this.