• Welsh Corgi (3/31/2013)


    Lynn Pettis (3/31/2013)


    Perhaps something more like this:

    SELECT

    j.job_id,

    s.srvname,

    j.name,

    js.step_id,

    js.command,

    j.enabled ,

    js.last_run_date,

    js.last_Run_Time,

    js.last_run_duration,

    msdb.dbo.Agent_datetime(js.last_Run_Date, js.last_Run_Time) AS Run_Datetime,

    dateadd(second, ((js.last_run_duration / 10000) * 3600) + (((js.last_run_duration / 100) % 60) * 60) + (js.last_run_duration % 60), msdb.dbo.Agent_datetime(js.last_Run_Date, js.last_Run_Time)) as EndRunDate

    FROM

    dbo.sysjobs j

    JOIN dbo.sysjobsteps js

    ONjs.job_id = j.job_id

    JOIN master.dbo.sysservers s

    ONs.srvid = j.originating_server_id

    WHERE

    j.name = 'TestJob';

    If you execute the code you will get the following error:

    Msg 241, Level 16, State 1, Line 2

    Conversion failed when converting date and/or time from character string.

    Thanks for you reply.

    Runs just fine on my system. Perhaps now is the time you should consider my original advise and create a mirror of your system tables, insert some of your data and let us try against what you are running against.