So you have your time in seconds and you want to display it as hours, minutes, and seconds. This probably isn't the only way to do it, but it's the way I came up with. If you have another method (especially if it's better) send it to me by replying to this FAQ. I'll include it and give you proper credit. Or create another FAQ with your solution.
DECLARE @mytime INT DECLARE @myhour INT DECLARE @mymin INT DECLARE @mysec INT SET @mytime = 3601 --or whatever value of seconds you have SET @myhour = (SELECT @mytime/3600) SET @mytime = (SELECT @mytime%3600) SET @mymin = (SELECT @mytime/60) SET @mysec = (SELECT @mytime%60) SELECT CAST(@myhour AS VARCHAR(2)) + ':' + CAST(@mymin AS VARCHAR(2)) + ':' + CAST(@mysec AS VARCHAR(2))
That won't add the leading zeros.
You can replace the SET @mytime = 3601 line with something like: SET @mytime = (SELECT DATEDIFF(ss, GETDATE()-100, GETDATE())) or whatever you need for your purposes.