Hi,
I have an SSRS report that displayed the production data. It consist of data from 1st-Shift and 2nd-Shift . My SSRS has a parameter with FromDate and Todate, Time. the default date is today's date. My requirements is to obtain the data of 1st shift and 2nd shift on the same day and displayed into one report with separate column for 1st shift and 2ns shift. The 1st shift is always start at 6:00AM and end at 2:00PM while the 2nd shift start at 2:00PM and end at 10:00PM
Btw, This report is run every hour. THe objective is to gather how the production perform.
Any help is very much appreciated. Thanks
Sample DDL
Create table #sample (ID nvarchar(5), DateandTime datetime, qty int) Insert into #sample(ID, dateandtime,qty) values('XXXX','2014-05-30 00:33:18.000',1) Insert into #sample(ID, dateandtime,qty) values('TTTT','2014-05-30 05:20:57.000',1) Insert into #sample(ID, dateandtime,qty) values('XXXX','2014-05-29 23:09:33.000',1) Insert into #sample(ID, dateandtime,qty) values('XXXX','2014-05-30 03:45:08.000',1) Insert into #sample(ID, dateandtime,qty) values('TTTT','2014-05-30 04:53:55.000',1) Insert into #sample(ID, dateandtime,qty) values('XXXX','2014-05-30 06:00:06.000',1) Insert into #sample(ID, dateandtime,qty) values('XXXX','2014-05-30 06:15:41.000',1) Insert into #sample(ID, dateandtime,qty) values('TTTT','2014-05-30 06:07:08.000',1) Declare @timezoneOffset int, @D1 datetime, @D2 datetime, @Stime nvarchar(8), @ETime nvarchar(8),@FromDatetime datetime, @ToDatetime datetime Set @timezoneOffset=8 Set @D1='2014-05-30' Set @D2='2014-05-30' set @Stime='06:00 AM' set @Etime='02:00 PM' Set @FromDatetime= @D1 +''+@Stime Set @ToDatetime= @D2 +''+@Etime SELECT * FROM #sample WHERE DATEADD(HOUR,convert(int,@timezoneOffset), dateandtime) BETWEEN (@Fromdatetime) AND (@ToDatetime)