System table sysjobschedules from MSDB database has four columns schedule_id, job_id, next_run_date and next_run_time. The datetime value is splitted into two columns next_run_date and next_run_time in the form of integers with the format YYYYMMDD and HHMMSS respectively. This table has the informations of all the scheduled jobs
If you want to have a report that shows the jobs with next executable date in DATETIME format, you can use the following methods
Source Data
create table #sysjobschedules
(
schedule_id int identity(1,1),
job_id uniqueidentifier default newid(),
next_run_date int,
next_run_time int
)
insert into #sysjobschedules (next_run_date,next_run_time)
select 20120618, 182326 union all
select 20120522, 71920 union all
select 20120708, 1015 union all
select 20120901, 220019 union all
select 20121211, 130659
Method 1 : Convert date and time values and add them select
next_run_date,
next_run_time,
next_run_date1+ stuff(stuff(next_run_time1,5,0,':'),3,0,':') as next_run_datetime
from
(
select
next_run_date,
next_run_time,
convert(datetime,cast(next_run_date as char(8)),112) as next_run_date1,
right('00000'+cast(next_run_time as varchar(6)),6) as next_run_time1
from
#sysjobschedules
) as t
Method 2 : Apply arithmetic operators to create time and add with converted date select
next_run_date,
next_run_time,
dateadd
(
second,
next_run_time/10000*3600+next_run_time/100%100*60+next_run_time%100,
cast(cast(next_run_date as char(8)) as datetime)
) as next_run_datetime
from
#sysjobschedules
Method 3 : Apply arithmetic operators and make use of implicit convertion select
next_run_date,
next_run_time,
dateadd
(
second,
next_run_time/10000*3600+next_run_time/100%100*60+next_run_time%100,
ltrim(next_run_date)
) as next_run_datetime
from
#sysjobschedules
In all cases the result is
next_run_date next_run_time next_run_datetime
------------- ------------- -----------------------
20120618 182326 2012-06-18 18:23:26.000
20120522 71920 2012-05-22 07:19:20.000
20120708 1015 2012-07-08 00:10:15.000
20120901 220019 2012-09-01 22:00:19.000
20121211 130659 2012-12-11 13:06:59.000