January 31, 2005 at 2:13 am
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? |
January 31, 2005 at 3:55 am
SELECT *
FROM t
WHERE CONVERT(CHAR(6),t.testdate,112) < CONVERT(CHAR(6),getdate(),112)
February 2, 2005 at 11:19 am
I use this way,
select * from t
where year(testdate)*100+Month(testdate) < year(GetDate())*100+month(GetDate())
February 3, 2005 at 12:06 pm
select * from t
where DATEDIFF(m, testdate, GetDate()) > 0
February 5, 2005 at 7:57 am
SELECT * from t Where year(t.testdate)=(year(getdate())-1) and month(t.testdate)=month(getdate())
James Horsley
Workflow Consulting Limited
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply