• dwain.c (1/15/2013)


    2. When you check for a date range, BETWEEN is not recommended. You should use >= @StartDate and <= @EndDate.

    I'd like to expand on this one a bit. Actually, it should be:

    ... DateColumn >= @ StartDate and DateColumn < @EndDate

    For example, all records rows where the data is in the month of March 2012:

    declare @StartDate datetime = '20120301', -- Using datetime as the data is date/time oriented

    @EndDate datetime = '20120401'; -- or dateadd(mm,1,@StartDate)

    ... DateColumn >= @ StartDate and DateColumn < @EndDate