I'm trying to format the LAST_RUN_Date and the END_RUN_TIME in the Job history table but I'm not cutting it.
I hoping to get the DateTime Formated correctly for the Start and the End of the Job Step.
The commented out part does not work but if you look at you should be able to determine what I'm trying to do.
I'm filtering on a specific job in this case.
SELECTj.job_id,
s.srvname,
j.name,
js.step_id,
js.command,
j.enabled ,
last_run_date
,
msdb.dbo.Agent_datetime(last_Run_Date, last_Run_Time) AS Run_Datetime
--,
-- Dateadd(second, Datediff(second, 0, msdb.dbo.Agent_datetime(19000101, last_Run_Duration)), msdb.dbo.Agent_datetime(last_Run_Date, last_Run_Time)) AS Run_Endtime
--Stuff(Stuff(RIGHT('000000'+ Cast(last_Run_Duration AS VARCHAR(6)), 6), 5, 0, ':'), 3, 0, ':') AS run_duration
FROMdbo.sysjobs j
JOINdbo.sysjobsteps js
ONjs.job_id = j.job_id
JOINmaster.dbo.sysservers s
ONs.srvid = j.originating_server_id
WHERE j.name = 'Any Job Name'
Any help would be greatly appreciated.
Thanks.
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/