How to display a time span of seconds in hh:mm:ss format in Reporting Services

reporting-servicesssrs-2008time

In MS Reporting Services 2008, I have a field that is a duration stored as seconds. Is there a slick way to get it into hh:mm:ss format in a group section of the report?

Best Answer

If you just want to display it, convert in an expression for the Value of the textbox:

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

If you want to do calculations on it, convert the seconds to a DateTime in your dataset. Using SQL:

SELECT DATEADD(ss, MySecondsField, '1900-01-01') AS SecondsAsDateTime
FROM TimeTable

In Linq this would be something like:

var qry = from Q in t.TimeList
    select new
    {
        SecondsAsDateTime = DateTime.Today.AddSeconds(Q.MySecondsField) 
    };

Then you can just format it as a normal DateTime.