views:

314

answers:

1

I'm using SSRS 2005 and I need to convert time from a serial unix time like 3412.254263 to a duration like 166:12:35 where the second format is HH:MM:SS.

All .NET code should work, but I can't find any function that does not include the date or does not treat the result as a duration.

Any help would be appreciated!

+1  A: 
Public Shared Function formatSeconds(ByVal seconds As Double) As String
    Dim ts As TimeSpan = TimeSpan.FromSeconds(seconds)
    Return String.Format("{0:00}:{1:00}:{2:00}", Math.Floor(ts.TotalHours), ts.Minutes, ts.Seconds)
End Function

EDIT: I placed it in a function, with VB.NET syntax.

Matthew Flaschen
How do I wrap that in a function? So that it takes in a value and spits out the result?
CodingIsAwesome
When I warp that up like:Public Function andrewsconversion(mytime)TimeSpan ts = TimeSpan.FromSeconds(mytime);andrewsconversion = String.Format("{0:00}:{1:00}:{2:00}", Math.Floor(ts.TotalHours), ts.Minutes, ts.Seconds);End FunctionI get 'TimeSpan' is a type and cannot be used as an expression.
CodingIsAwesome
This works when converted seconds (not epoch(unix)), which is wonderful thank you for time.
CodingIsAwesome