Why so complicated?
Try this is the top of your query, assuming the name of your parameter is "String":
--DECLARE @string VARCHAR(20) = '7/22/2014-7/29/2014'
DECLARE @startDate DATE, @endDate DATE
SET @startDate = LEFT(@string,CHARINDEX('-',@string)-1)
SET @endDate = RIGHT(@string,LEN(@string)-CHARINDEX('-',@string))
--SELECT @startDate, @endDate
select * from mytable where theDate between @startDate and @endDate
No comments:
Post a Comment