Hi,Just made changes with my requirements. I need to dynamically back track 1 day at a time in extracting of records if my query does not found any records. actually i made already a query i though its working but need to change dynamically. i though only Sunday that we don't have any transaction but in case there's a holiday which that fall in week days which i did not consider this scenario that's why i change my Sql statement. just stuck up for this requirements. Thanks in advance. your help is very much appreciated.With my solution, i encounter errorIncorrect syntax near '@PFromDate'Cannot use a BREAK statement outside the scope of a WHILE statement.Here is my sample and DDLCreate table #SampleData(Prodid nvarchar(35), model nvarchar(35), Trandate datetime)GoInsert into #SampleDataSelect 'TRC003328042','DRDRZR2BLK','2013-08-31 04:30:33.000' union all---SaturdaySelect 'TRC003327670','DRDRZR2BLK','2013-08-31 02:40:23.000'union all---SaturdaySelect 'TRC003327822','DROIDRZR','2013-08-31 05:17:28.000'union all---SaturdaySelect 'TRC003328342','DROIDRZR','2013-08-31 08:10:27.000'union all---SaturdaySelect 'TRC003328387','DROIDRZR','2013-08-31 09:22:01.000'union all---SaturdaySelect 'TRC003322836','DRDRZRHDBLK','2013-08-30 23:40:19.000'union all---SaturdaySelect 'TRC003326586','DROIDBIO2','2013-08-31 05:50:47.000'union all---SaturdaySelect 'TRC003325460','DROIDBIO2','2013-08-30 22:36:50.000'union all---SaturdaySelect 'TRC003328994','DRDRZR2WHT','2013-09-02 04:33:44.000'union all-- MondaySelect 'TRC003328998','DRDRZR2WHT','2013-09-02 06:37:13.000'-- Monday --Created SSRS ParameterDeclare @FromDate datetime, @ToDate datetime, @rowcount int,@Fromtime nvarchar(6), @Totime nvarchar(6) ,@timezoneOffset intset @FromDate='9/2/2013' --Mondayset @ToDate='9/3/2013'Set @Fromtime='6:00 AM'Set @Totime='6:00 AM'set @timezoneOffset=8set @rowcount=0 --Add in Dataset Properties->ParameterParameter name--------Parameter value@PFromDate=Parameters!FromDate.Value &" "&Parameters!FromTime.Value@PToDate=Parameters!ToDate.Value &" "&Parameters!ToTime.Value --Text Query expressionIF OBJECT_ID('tempdb..#Temp') IS NOT NULL DROP TABLE [dbo].[#Temp] Create table #Temp (Prodid nvarchar(35), model nvarchar(35), Trandate datetime) While (1=1) BEGIN Insert into #Temp(Prodid,model,Trandate) select Prodid, model, Trandate from #SampleData Where DATEADD(HOUR,convert(int,@timezoneOffset), Trandate) BETWEEN DATEADD(DAY,0,@PFromDate) AND DATEADD(DAY,0,@PToDate) IF @ROWCOUNT < 0 BEGIN --got an error from this portion @PFromDate=@PFromDate -1 @PToDate=@PToDate-1 END ELSE BREAKEND --Query validation to get the final result setWith CTE AS(select * from #Temp)SELECT * from CTE