Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display Seconds Count in HH:MM:SS format in SSRS 2008

I have a table with a column, TotalTime that is an Integer value in seconds.

In Visual Studio / SSRS 2008 I want to display it in HH:MM:SS format.

Thanks!

like image 791
Amarundo Avatar asked Nov 20 '12 20:11

Amarundo


2 Answers

Just use an expression that adds that number of seconds to a zero time value

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

If it is larger than 24 hours, then you can use the following formula that adds the days portion:

=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"))
like image 100
Chris Latta Avatar answered Oct 24 '22 07:10

Chris Latta


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

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

In this case, for example 90000sec will be displayed as: 25:00:00

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

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

90000sec will be shown as: 1:01:00:00

like image 39
Konrad Z. Avatar answered Oct 24 '22 07:10

Konrad Z.