You only need to change the convert to datetime. Notce that I have replaced the CAST function with CONVERT.
I really don't understand why you store dates in a varchar column. As you can see it can give you all sorts of problems.Code:CREATE PROCEDURE spVisitors AS select convert(varchar,(getdate()-(day(getdate())-1)),101) as startdate, convert(varchar,getdate(),101) as enddate, sum([count]) as visits, sum(qcount) as requests, pid from tblcounterv3 where (convert(varchar,convert(datetime,countdate,103),101) between convert(varchar,(getdate()-(day(getdate())-1)),101) and convert(varchar,getdate(),101)) group by pid GO





Reply With Quote