Timespan

I am trying to display time difference between an Admission Date and a Discharge date as follows:

Admission Date:8/26/2015 6:59pm

Discharge Date:9/1/2015 6:49pm

Time Display 5D 23H

I used the following expression but came up with an error

Not sure what I am doing wrong or if this is the best expression to use

=(TimeSpan.FromMinutes(Avg(DateDiff(n,<Fields!Admission_Date.Value>,<Fields!Actual_Discharge_Date.Value>)))).Days
 d &

(TimeSpan.FromMinutes(Avg(DateDiff(n,<Fields!Admission_Date.Value>,<Fields!Actual_Discharge_Date.Value>)))).Hours
 h &

(TimeSpan.FromMinutes(Avg(DateDiff(n,<Fields!Admission_Date.Value>,<Fields!Actual_Discharge_Date.Value>)))).Minutes
& m ))))

Any suggestions would be appreciated

Thank you in advance

September 4th, 2015 10:43am

Hi MLOG,

According to your description, you want to calculate time difference between two date time values, right?

In Reporting Services, we are able to return the difference between the Start datetime or time and the End datetime or time field types using DateDiff() function. In your scenario, you can specify the interval unit as hour then calculate the corresponding day and hour values. You can use the expression like below:
=DateDiff("h",Fields!Admission_Date.Value,Fields!Actual_Discharge_Date.Value)\24 & "D " & DateDiff("h",Fields!Admission_Date.Value,Fields!Actual_Discharge_Date.Value) mod 24 & "H"

If you have any question, please feel free to ask.

Best regards,
Qiuyun Yu

Free Windows Admin Tool Kit Click here and download it now
September 6th, 2015 10:45pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics