I have a situation where my customer wants to run a report by any one of 4 dates. I have this in my where clause:
and (case when @DateType = 'Date1' then ([filename].[Date1] between @StartDate and @StopDate)
when @DateType = 'Date2' then ([filename].[Date2] between @StartDate and @StopDate)
when @DateType = 'Date3' then ([filename].[Date3] between @StartDate and @StopDate)
when @DateType = 'Date4' then ([filename].[Date4] between @StartDate and @StopDate)
end)
the error I get is:
Msg 156, Level 15, State 1, Procedure sp_RamAccessSummary, Line 72
Incorrect syntax near the keyword 'between'.
The first Between in line 72
Any idea what I am doing here??? thanks in advance
and (case when @DateType = 'Date1' then ([filename].[Date1] between @StartDate and @StopDate)
when @DateType = 'Date2' then ([filename].[Date2] between @StartDate and @StopDate)
when @DateType = 'Date3' then ([filename].[Date3] between @StartDate and @StopDate)
when @DateType = 'Date4' then ([filename].[Date4] between @StartDate and @StopDate)
end)
the error I get is:
Msg 156, Level 15, State 1, Procedure sp_RamAccessSummary, Line 72
Incorrect syntax near the keyword 'between'.
The first Between in line 72
Any idea what I am doing here??? thanks in advance