The question is not really about datetime precision, but string comparison.
If the comparison value had been declared as datetime, then the other values would be implicitly converted to datetime as well and the statement would return Yes.
declare @d as datetime
set @d = '2011-07-31 00:00:00.000'
IF @d BETWEEN '2011-07-01' and '2011-07-31'
PRINT 'Yes'
ELSE
PRINT 'No'
The question as it stands could just as well have been this
if ('abcd' between 'ab' and 'abc')
print 'yes'
else
print 'no'