g.britton (11/3/2015)
This might do it:
SELECT j.NAME
, s.next_run_time
FROM dbo.sysjobschedules s
CROSS APPLY (
SELECT datepart(YEAR, getdate()) * 10000 + datepart(MONTH, getdate()) * 100 + datepart(DAY, getdate()) AS today
, datepart(HOUR, getdate()) * 10000 + datepart(MINUTE, getdate()) * 100 + datepart(SECOND, getdate()) AS rightnow
) _
INNER JOIN dbo.sysjobs j
ON s.job_id = j.job_id
WHERE next_run_date = today
AND next_run_time BETWEEN rightnow
AND rightnow + 5 * 10000
just comment out the second part of the where for all jobs scheduled today
Note: if you want to easily code around the problem caused by msdb storing job dates and times as integers in two separate columns, use this:
dbo.agent_datetime(s.next_run_date, s.next_run_time) As NextRunDateTime
which will return a DATETIME data type. If you have any schedules where next_run_date = 0, you'll get an error, so exclude them in the WHERE clause.
Rich