SSRS 格式以 dd:hh:mm:ss 计算的时间跨度
问题描述:
我有一份报告,其中一个字段计算表达式中的时间跨度,例如
I have a report and one of the fields calculates a timespan in an expression e.g
=Fields!Date1.Value-Fields!Date2.Value
我想以 dd:hh:mm:ss 格式显示天、小时、分钟和秒.如果我只是离开表达式它有点工作,但我得到了我不想要的毫秒,如果没有天,那么该值就会消失.
I would like to display in the format dd:hh:mm:ss so days,hours,minutes and seconds. If i just leave the expression it sort of works but i get milliseconds which i don't want and if there are no days then that value disappears.
我见过很多使用格式来获取 HH:mm:ss 的例子,但没有看到如何做这些日子.
I've seen lots of examples using formatting to get HH:mm:ss but not on how to do the days.
答
基于@alejandro 的回答,我最终得到了
Based on @alejandro's answer I ended up with
=Format(Floor(DateDiff("s",Fields!Date1.Value,Fields!Date2.Value)/86400),"00")
& ":" & Format(DateAdd("s", (Fields!Date2.Value-Fields!Date1.Value).TotalSeconds,
"00:00:00"), "HH:mm:ss")
只是做直接减法似乎没有用.
just doing the straight subtraction didn't seem to work.