• You can actually avoid using trunctation. Consider that if @t is the sql agent time, @t % 100 will be seconds, @t % 10000 - @t % 100 will be minutes * 100, and @t - @t % 10000 will be hours * 10000. So, the subsequent division by 100 or 10000 is already an integer value.

    DECLARE @t int = 1234556; --4546 --5; --56; --1234556;

    SELECT

    @t AS AgentDuration,

    (@t - @t % 10000) /10000 AS hours,

    (@t % 10000 - @t % 100) /100 AS minutes,

    @t % 100 AS SECONDS,

    ((@t - @t % 10000) /10000) * 60 * 60

    + ((@t % 10000 - @t % 100) /100) * 60

    + @t % 100 AS totalseconds

    Added bonus: it'll work for negative values too. Not that output will mean anything (GIGO!)