Home Forums SQL Server 2005 Development Producing dates from SYSJOBS and SYSJOBHISTORY RE: Producing dates from SYSJOBS and SYSJOBHISTORY

  • Will not work for "small" times, as 115 (00:01:15)

    Use this

    DECLARE@rundate INT,

    @runtime INT,

    @duration INT

    SELECT@rundate = 20080504,-- May 4, 2008

    @runtime = 42412,-- 4:24:12 AM,

    @duration = 115-- 00:01:15

    SELECTrundate,

    runtime,

    duration,

    rundate + runtime AS start,

    rundate + runtime + duration AS finish

    FROM(

    SELECTCAST(STR(@rundate, 8, 0) AS DATETIME) AS rundate,

    CAST(STUFF(STUFF(REPLACE(STR(@runtime, 6), ' ', '0'), 3, 0, ':'), 6, 0, ':') AS DATETIME) AS runtime,

    CAST(STUFF(STUFF(REPLACE(STR(@duration, 6), ' ', '0'), 3, 0, ':'), 6, 0, ':') AS DATETIME) AS duration

    ) AS d


    N 56°04'39.16"
    E 12°55'05.25"