From your other questions, it looks like SQL Server.
SQL Server 2 responses are already set to not SARGable (link) ; they cannot use indexes.
WHERE datecolumn < DATEADD(month, -3, GETDATE())
Create a date 3 months ago and test it; this will allow the use of indexes. This statement is true for any DBMS.
If you have passed the full calendar months, for example
- current date = February 24, 2011
- 3 months ago = November - 2010 (excluding the day of the month)
- required = any date in November 2010 and earlier
WHERE datecolumn <= DATEADD(month, datediff(month, 0, getdate()) -2, 0)
source
share