Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
imblogger
Starting Member
2 Posts |
Posted - 2008-07-07 : 03:42:36
|
HiI want to select only last month from 2004 to 2006 and from 2007 to 2008 all the monthscan u help me out |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-07 : 03:55:33
|
didnt get that? do you mean you need to filter out records whose datefield staisfies the above condition? |
 |
|
imblogger
Starting Member
2 Posts |
Posted - 2008-07-07 : 03:59:05
|
yesi have date column which have date from 2002 onwordsi want to select 2004 2005 2006 with only December and from 2007 to 2008 all months |
 |
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2008-07-07 : 04:08:03
|
Guaranteed not to use any index that you may have, but will do as you want.SELECT SomeColumns FROM someTable WHERE (year(SomeDate) IN (2004,2005,2006) AND Month(SomeDate) = 12) OR (year(SomeDate)>=2007) Does that do what you want?--Gail ShawSQL Server MVP |
 |
|
|
|
|