all groups > sql server reporting services > august 2004 >
You're in the

sql server reporting services

group:

Displaying seconds value as [mm]:ss


Displaying seconds value as [mm]:ss david.glasgow NO[at]SPAM unison.co.nz
8/11/2004 9:15:13 PM
sql server reporting services:
Hello

I am returning a int value from a database which is for an elasped
time in seconds. I want to convert this to mm:ss, however I dont want
it roll over to hours or days.

I trying something along the lines of:

=String.Format("{0:0:mm:ss}",CDate("0:0:0").AddSeconds(Sum(Fields!Airtime.Value)))

However this still allows values to go to hours/days, just doesn't
display them

So for example a value returned from the database of 19257 (seconds)
should be displayed as 320:57 ([mm]:ss)

This is achived in excel by

19257 / 24 = 802.375 / 60 = 13.37291667 /60 = 0.222881944

Then change the format on the cell to [mm]:ss

Then 320:57 is displayed.

Any ideas would be great

Thanks

Re: Displaying seconds value as [mm]:ss Lev Semenets [MSFT]
8/11/2004 10:58:46 PM
You could create custom function, something like this:
Function Seconds2mmss(ByVal seconds As Integer) As String
Dim ss As Integer = seconds Mod 60

Dim mm As Integer = seconds - ss * 60

Seconds2mmss = String.Format("{0:0}:{1:00}", mm, ss)

End Function

and then call it from textbox expression:

=Code.Seconds2mmss(Sum(Fields!Airtime.Value))

--
This posting is provided "AS IS" with no warranties, and confers no rights.


[quoted text, click to view]

Re: Displaying seconds value as [mm]:ss david.glasgow NO[at]SPAM unison.co.nz
8/12/2004 6:41:04 PM
Thanks for that, the final code that returned the result was:

Function Seconds2mmss(ByVal seconds As Integer) As String
Dim ss As Integer = seconds Mod 60
Dim mm As Integer = (seconds - ss) / 60
Seconds2mmss = String.Format("{0:0}:{1:00}", mm, ss)
End Function

AddThis Social Bookmark Button