SELECT COUNT(td.timeSheetID) FROM TimeSheet t
INNER JOIN TimeSheetDetail td ON t.timeSheetID = td.timeSheetID
WHERE (CONVERT(DateTime, t.setDate, 23) BETWEEN '2012-08-10' AND '2012-08-12')
AND t.employeeID = 300
The above code returns the value i'm looking for. However, when i do the following, i get nothing:
SELECT COUNT(td.timeSheetID) FROM TimeSheet t INNER JOIN TimeSheetDetail td ON t.timeSheetID = td.timeSheetID
WHERE (CONVERT(DateTime, t.setDate, 23) = '2012-08-11')
AND t.employeeID = 300
setDate value in table looks as:
2012-08-11 18:00:19.000
My questions:
Why the code in first scenario works fine whereas in the second one doesn't work?
Why the code in the first scenario doesn't return a value when i put the actual range as BETWEEN '2012-08-11' AND '2012-08-11' ... How can i solve the problem, i don't time to be considered during the range/filtering. I'm only considered about date.