SQLTeam.com | Weblogs | Forums

Search between months


#1

I have a table with 10 years of data. One column is a date field. I want to be able to search between months ie March 1st - May 31st for all the years in the table, but I can't figure out how to do this. Can anyone help please. Thank you.
ps I guess the question is not the best framed in the world, so in the hope of making things a wee bit clearer, in my mind the query would be something along the lines of :-
Select * from MyTable where Date between @month1 and @month2


#2
use master
go

create table #showlove(name varchar(50), eventdate date)

insert into #showlove
select name, DATEADD(yy,object_id, create_date) 
from sys.objects where object_id between 1 and 500

select * 
  from #showlove where MONTH(eventdate) between 1 and 5


drop table #showlove

#3

Blimey! Fantastic! Thank you.