0
我有一份水晶报表,它用饼图显示代理的全天活动。在细节部分它显示:水晶报表函数用于将Seconds转换为Timespan格式
- 活性[字符串]
- StartedAt [DATETIME]
- EndedAt [DATETIME]
- 时间[以秒EndedAt和StartedAt之间的差异 - 整数]
报告数据是GroupedBy活动并按持续时间汇总。
目前持续时间以秒为单位显示,但我需要格式化为02h:30m:22s:15ms。为此,我在Formula Workshop编辑器的Crystal Report中编写了一个自定义函数,如下所示,但看起来语法不正确(关键字Long的错误消息:“缺少一个变量类型(例如'String')。” )。有人可以帮忙吗?
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