July 28, 2014 at 8:55 am
I'm calculating the difference between two text boxes which record the time in seconds. When I get negative results EG -223 seconds, how can I display this as -00:03:43?
Cheers.
July 28, 2014 at 9:09 am
Didn't realize that this was for reporting services until I was posting. Maybe this T-SQL code might give you an idea.
DECLARE @Seconds int = -223
SELECT CASE WHEN @Seconds < 0 THEN '-' ELSE '' END +
RIGHT( '0' + CAST( ABS( @Seconds / 3600) AS VARCHAR(2)), 2) + ':' +
RIGHT( '0' + CAST( ABS( (@Seconds % 3600) / 60) AS VARCHAR(2)), 2) + ':' +
RIGHT( '0' + CAST( ABS( (@Seconds % 3600) % 60) AS VARCHAR(2)), 2)
July 30, 2014 at 6:21 am
Thanks for that. I can use that in my SQL script to get the result and display from their. Saves messing about in Reporting Services.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply