where dsh.aDate >= @a AND dsh.aDate < DATEADD(dd,1,@b);You will notice that I made several changes to your query - the data types of @a and @b, the string literal for dates using YYYYMMDD format, and changing the where clause as I described above.