SSRS计算两个日期之间的持续时间

时间:2015-05-06 19:25:20

标签: sql reporting-services ssrs-2008-r2 ssrs-2012

如何在SSRS表达式中编写以下SSRS计算

下面的实际计算示例 =((deldate+deltime) –(orddate+ordtime))*24

deldate     delTime  orddate    ordTime  *24
13/01/2015  14:25   14/01/2015  13:55    23.50
20/01/2015  12:00   20/01/2015  17:02    5.03

这适用于SQL Toad,但不适用于SSRS

(TO_DATE(TO_CHAR(A.DELDATE,'DD/MM/YYYY') ||' '|| TO_CHAR(A.DELTIME,'HH24:MI'),'DD/MM/YYYY HH24:MI') - TO_DATE(TO_CHAR(A.ORDDATE,'DD/MM/YYYY') ||' '|| TO_CHAR(A.ORDTIME,'HH24:MI'),'DD/MM/YYYY HH24:MI'))*24 AS "DiffinHours",

1 个答案:

答案 0 :(得分:2)

TO_CHAR更改为Format,将TO_DATE更改为CDate,并使用DateDiff代替减去。要获得小数小时数,请找出以分钟为单位的差异除以60.0:

=DateDiff(DateInterval.Minute, 
          CDate(Format(Fields!deldate.Value, "MM/dd/yyyy") & " " & Format(Fields!deltime.Value, "HH:mm")), 
          CDate(Format(Fields!orddate.Value, "MM/dd/yyyy") & " " & Format(Fields!ordtime.Value, "HH:mm"))
         ) / 60.0