i have a requirement to get the appropriate RunID based on the Starttime.
I'm not able to get results if Starttime is beween 00:00 and 05:00 for ABC Dataset. Please help.
declare@ScheduleTable(Datasetsysname,RunIDSMALLINT,StartMinTimeTIME)
INSERTINTO@Schedule
select'ABC',1,'22:01'unionALL
select'ABC',2,'05:01'unionALL
select'ABC',3,'14:01'unionALL
select'XYZ',1,'03:01'unionALL
select'XYZ',2,'12:01'unionALL
select'XYZ',3,'20:01'
Declare@DatasetNamesysname='XYZ'
Declare@StartTimedatetime='2014-01-19 01:21:39.000'
SelectRunID,@StartTime,CAST(CAST(@StartTimeASDATE)ASDATETIME)+CAST(StartMinTimeASTIME)
from@Schedulewhere Dataset=@DatasetName
andDATEPART(hour,cast(@StartTimeasTIME))>=DATEPART(hour,StartMinTime) andDATEPART(hour,cast(@StartTimeasTIME))<=(DATEPART(hour,StartMinTime)+ 8)