I have a crystal report where it shows the Agent's activities throughout the day with a pie chart. In the details section it is displaying:
- Activity [string]
- StartedAt [DateTime]
- EndedAt [DateTime]
- Duration [The difference between EndedAt and StartedAt in seconds - Integer]
Report data is GroupedBy Activity and summarized by Duration.
Currently Duration is shown in seconds but I need to format it 02h:30m:22s:15ms. For that I wrote a custom function in Crystal Report in the Formula Workshop editor as follows, but it looks like the syntax is not right (Error message on keyword Long: "A variable type (for example, 'String') is missing."). Can someone help?
Function GetTimeSpanString(seconds as Long)
Dim ts As TimeSpan = TimeSpan.FromSeconds( seconds );
GetTimeSpan = string.Format("{0:D2}h:{1:D2}m:{2:D2}s:{3:D3}ms",
ts.Hours,
ts.Minutes,
ts.Seconds,
ts.Milliseconds)
End Function