How to display in 24 hours in SSRS 2008 in the format HH: MM: SS

I have a report in SSRS 2008 that retrieves data from a table with a TotalTime column, which is an Integer value in seconds.

To display as time, I use this in an expression:

=Format(DateAdd("s", Fields!TotalTime.Value, "00:00:00"), "HH:mm:ss") 

(got it from here: Display the number of seconds in HH: MM: SS format in SSRS 2008 )

Now, when the value goes beyond 24 hours, it looks like a โ€œmoduleโ€. I mean this: if the value is 29 hours, instead of displaying 29:00:00 it will display 05:00:00. If a value of 51 hours will be displayed 03:00:00 (issued 48 hours).

How to solve this?

Thanks!

+1
reporting-services ssrs-2008
source share
3 answers

There are 86,400 seconds a day. So just use days if seconds are longer than this:

 =IIF(Fields!TotalTime.Value < 86400, Format(DateAdd("s", Fields!TotalTime.Value, "00:00:00"), "HH:mm:ss"), Floor(Fields!TotalTime.Value / 86400) & " days, " & Format(DateAdd("s", Fields!TotalTime.Value, "00:00:00"), "HH:mm:ss") 
+5
source share

For the format HH: mm: ss you can use this:

 =Floor(Fields!TotalTime.Value / 3600) &":"& Format(DateAdd("s", Fields!TotalTime.Value, "00:00"), "mm:ss") 

In this case, for example, 90,000 seconds will be displayed as: 25:00:00

For the format DD: HH: mm: ss use this:

 Floor(Fields!TotalTime.Value / 86400) &":"& Format(DateAdd("s", Fields!TotalTime.Value, "00:00:00"), "HH:mm:ss") 

90,000 seconds will be displayed as: 1: 01: 00: 00

+5
source share

You really need to use a day-based watch solution, which could potentially cause you daylight saving time problems.

 =Floor(Fields!TotalTime.Value / 3600) &":"& Format(DateAdd("s", Fields!TotalTime.Value, "00:00"), "mm:ss") 
0
source share

All Articles