convert seconds to hh:mm:ss
I have the following value: 124582 seconds that I want to convert to hh:mms in my ssrs report. Fields!Sec_Online.Value/3600 returns.. 34.606111... So I'm looking at over 24 hours.. I found another post that gets me close for anything under 24 hours. When =format(date.FromOAdate((Fields!Sec_Online.Value)/86400), "HH:mms") This returns 10:36:22 Any suggestions?
May 20th, 2008 2:23pm

You're going to have to do some calculations. Possibly use the custom code feature of reporting services. hrs = seconds / 3600leftover = seconds % 3600mins = leftover / 60secs = leftover % 60 Possibly this would work. You might have to play with it a bit. = (Fields!Sec_Online.Value / 3600) & ":" & ((Fields!Sec_Online.Value Mod 3600) / 60) & ":" & ((Fields!Sec_Online.Value Mod 3600) Mod 60)
Free Windows Admin Tool Kit Click here and download it now
May 20th, 2008 3:43pm

I was making this much harder than it had to be!! thanks.
May 20th, 2008 3:58pm

Mavern1ck wrote: I was making this much harder than it had to be!! thanks. I'm am known for doing the same. You're welcome.
Free Windows Admin Tool Kit Click here and download it now
May 20th, 2008 4:05pm

I need to further format this expression. in the :mms sections if the value is under 10 seconds this isn't returning a leading zero. ex: 12:6:6.. I want to show this as 12:06:06.. =int(sum(Fields!Sec_Online.Value)/3600) & ":" & int((sum(Fields!Sec_Online.Value) Mod 3600)/60) & ":" & (sum(Fields!Sec_Online.Value) Mod 3600) Mod 60
May 30th, 2008 9:48am

I know this is an old thread but I wanted to through this out there. I have fought with this all day and found another solution that might be helpful for those that are searching the forum.... http://msdn.microsoft.com/en-us/library/system.timespan.fromseconds.aspx
Free Windows Admin Tool Kit Click here and download it now
November 5th, 2010 1:58pm

To zero pad the result, use this: =right("0" & int(sum(Fields!Total_Login_Seconds.Value)/3600),2) & ":" & right("0" & int((sum(Fields!Total_Login_Seconds.Value) Mod 3600)/60),2) & ":" & right("0" & (sum(Fields!Total_Login_Seconds.Value) Mod 3600) Mod 60,2)
July 6th, 2012 9:59am

Much better solution: =Format(DateAdd("s", Fields!MySecondsField.Value, "00:00:00"), "HH:mm:ss") From: http://stackoverflow.com/questions/5332217/how-to-display-a-time-span-of-seconds-in-hhmmss-format-in-reporting-services Greetings.goDog
Free Windows Admin Tool Kit Click here and download it now
August 27th, 2012 8:42pm

I know this thread is old but did you figure out your answer? I used the below code but i get these results 28.611115:01:28 =(Fields!TimeSecs.Value / 3600) & ":" & ((Fields!TimeSecs.Value Mod 3600) / 60) & ":" & ((Fields!TimeSecs.Value Mod 3600) Mod 60) any suggestions
October 11th, 2012 2:35pm

try this: =Format(DateAdd("s", Fields!MySecondsField.Value, "00:00:00"), "HH:mm:ss")
Free Windows Admin Tool Kit Click here and download it now
October 11th, 2012 4:33pm

Sorry, I logged in before with the wrong account, I've been using this method for a while: =Format(DateAdd("s", Fields!MySecondsField.Value, "00:00:00"), "HH:mm:ss") and it works great. I think this solution is a lot cleaner than the one proposed here.goDog
October 11th, 2012 4:36pm

And you could also use the Round function to eliminate decimals if you decide to keep using the odd calculations solutions. goDog
Free Windows Admin Tool Kit Click here and download it now
October 11th, 2012 4:38pm

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

Other recent topics Other recent topics