• Do queries like this as a selection against a range in this form:

    where date >= @StartOfRange and date < @EndOf Range

    In the following code, it will be the same as this:

    where date >= '2008-01-01' and date < '2008-03-01'

    declare @year int

    declare @month int

    select @year = 2008, @month = 2

    select

    *

    from

    MyTable

    where

    -- Date on or after start of year

    MyTable.MyDate >= dateadd(month,(12*@Year)-22801+1,0)and

    -- Date before start of next month

    MyTable.MyDate < dateadd(month,(12*@Year)-22801+@Month+1,0)