• Queries for a date range should normally be in this form:

    where MyDatetimeColumn >= @StartDatetime and MyDatetimeColumn < @EndDatetime

    In other words greater than or equal to the first point in time that we know that we want, and less than the first point in time that we don't want.

    There is never any guarantee that the precision of time intervals will stay the same in future releases, so it is unrealistic to code end time as "2009-06-29 23:59:59.997", even if this is the last possible moment that we want to select with the current version of SQL Server. Just code it as less than '2009-06-30'.