I want to query my table against two dates and retrieve the records within them.
I declare my variables like so;
DECLARE @StartDate datetime;
DECLARE @EndDate datetime;
And set my variables like so;
SET @StartDate = 2012-08-01;
SET @EndDate = 2012-08-02;
My WHERE clause;
WHERE Date BETWEEN @StartDate AND @EndDate
No records are displayed when the query is executed, what’s my mistake? I’ve tried adding a time to the date but that doesn’t work either.
Do this instead
or better
This will return any data on 1 Aug, or anything marked as midnight on 2-Aug. It won’t return anything marked as eg: 9am on 2-Aug