i am fresher in SQL,i want write a query to get the last 24 hour jobs record from msdb.dbo.sysjobhistory,but i cant get because,here i get the run_date and run_time as like the number.how i will convert the run_date and run_time into datetime and get the last 24 hour job record.
i am using SQL Server 2000
thanks in advance
For databases after 2000, there is a function in the msdb database you can call that will return datetime:
If you are using sql 2000, you can copy the source of that function from a later version and create it in your instance of 2000. I wish I could take credit for all of this, but I originally found it here: mssqltips.com
Check out this post - it shows how to "decode" those
run_date
columns fromsysjobhistory
.You should be able to get the entries from the last 24 hours with a query something like this: