date comparison help | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

date comparison help

how to compare 2 dates but taking into consideration only the year and the month.
ex. i have table t with test_date as column
i want to : select * from t where t.test_date < getDate() but the comparison must be on month and year. For example t.test_date=2004/1 to be compared with 2005/1
How’s that?
Try this select * from t where year(test_date) < year(getDate()) and month(test_date)<month(getdate()) Madhivanan
select *
from t
where year(t.test_date) < year(getDate())
or (year(t.test_date) = year(getDate()) and month(test_date) < month(getDate())