Share via


Convert run_date and run_time into a DateTime Format

Question

Wednesday, October 25, 2017 2:20 PM | 2 votes

Hello Forum

Does anyone know how to convert the run_date and run_time in sysJobsHistory into a DateTime format?

Please click "Mark As Answer" if my post helped. Tony C.

All replies (7)

Wednesday, October 25, 2017 2:34 PM ✅Answered | 15 votes

There is actually an in-built function that will do this for you.

Select dbo.agent_datetime(run_date,run_time)
from dbo.sysjobhistory

Thanks for reading!
If you found my answer useful please mark as answered
David


Wednesday, October 25, 2017 3:31 PM

Thanks David

I'll give this a shot...

Please click "Mark As Answer" if my post helped. Tony C.


Friday, October 27, 2017 6:54 AM

Whaddayaknow!

After all these years with SQL Server, I still pick up bits and pieces here and there. Thanks David. :-)

Tibor Karaszi, SQL Server MVP (Web Blog)


Friday, October 27, 2017 7:00 AM

Awesome!

Was never aware of this

Thanks for the info David

Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh

My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page


Friday, February 23, 2018 3:48 PM

Hidden Gem :)

Please Mark This As Answer if it solved your issue 
Please Vote This As Helpful if it helps to solve your issue so that other forum members can benefit from it

Yuvraj Singh Bais


Wednesday, July 29, 2020 8:05 PM

What is the remedy for:

The EXECUTE permission was denied on the object 'agent_datetime', database 'msdb', schema 'dbo'.


Wednesday, July 29, 2020 8:47 PM

Rather than piggybacking on a two-year old thread, start a new thread describing your problem from start to end. Not the least in this case, we need to know the security context.

Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se