I've searched the boards and have tried many different approaches but I can't seem to get this to work. Basically I'm trying to write a stored procedure that accepts 5 parameters (@in_intStudID, @in_intClubID, @in-intSQLType, @in_dtDateFrom, @in_dtDateTo). If the @in_intSQLType = 1 Then I'm doing a search looking for a specific date. If it's equal to 3 then I'm doing a search looking for records Between 2 dates. SELECT s.studID, cm.clubID, s.studLName + ', ' + s.studFName AS studFullName, s.studEmail FROM tblClubMembership cm INNER JOIN tblStudent s ON cm.studID = s.studID WHERE s.studID = @in_intStudID AND cm.clubID = @in_intClubID AND CASE @in_intSQLType WHEN 1 THEN [CONVERT(DATETIME, CONVERT(VARCHAR(11), cm.joinDate, 101)) = @in_dtDateFrom] ELSE [CONVERT(DATETIME, CONVERT(VARCHAR(11), cm.joinDate, 101)) BETWEEN @in_dtDateFrom AND @in_dtDateTo] END
I initially tried doing it without using @in_intSQLType, using only @in_dtDateTo = NULL, but I wasn't able to get that working.Can anyone tell me what I'm doing wrong? Should I just use an If-Else here, or is the Case the better way to go? Or should I stick with the @in_dtDateTo = NULL method?Thanks in advance for any and all help that you can give.DTFanEver-hopeful programmer-in-training 