• Lynn Pettis (3/31/2013)


    Welsh Corgi (3/31/2013)


    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.

    What job did you create?

    What was in the execute of the step(s)?

    You can't answer my questions or provide the information I request and you expect me to answer yours?

    It doesn't matter what job I created or what I did in the job step(s). The job ran and put data in the tables that when accessed by your query with my added code to compute the End Date ran without problems.

    This means there is more going on on your system and that we need to see some data from you in order to help answer your questions. I am more than willing to help, but you really need to help in that regard.

    I asked you for that information so that I could replicate what you did .

    Disregard my post

    Thank you.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/