Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

TSQL Help needed using time datatype

$
0
0

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)


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>