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 |
|
Gary Costigan
Yak Posting Veteran
95 Posts |
Posted - 2004-11-15 : 19:11:58
|
| I would like to set up a condition where the Query searches for data within the same date range over the years of data stored in the server. I only want to see data between Dec 20th and Jan 06th.My test statement looks like this.WHERE [AutoTACurrentPayDaily].[CompanyCode]='AA' AND [AutoTACurrentPayDaily].[PayCode]IN('SK', 'SKF', 'SKU', 'FML', 'NC', 'UA')AND [AutoTACurrentPayDaily].[PayHours]>'0'AND [AutoTACurrentPayDaily].[PayDate]<=[AutoTACurrentPayDaily].[PayPeriodEnd]AND [AutoTACurrentPayDaily].[PayDate]>= '12/20/2002'AND [AutoTACurrentPayDaily].[PayDate]<= '01/06/2003'Which gives me the data for 2002/2003. How do I get it to show me Dec 2003 and Jan 2004 as well??Thanks.GC |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-11-15 : 20:08:30
|
| something likeAND (dateadd(yy, 1900 - datepart(yy,[AutoTACurrentPayDaily].[PayDate]), [AutoTACurrentPayDaily].[PayDate])>= '12/20/1900'or dateadd(yy, 1900 - datepart(yy,[AutoTACurrentPayDaily].[PayDate]), [AutoTACurrentPayDaily].[PayDate])<= '01/06/1900')==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
Gary Costigan
Yak Posting Veteran
95 Posts |
Posted - 2004-11-16 : 10:30:15
|
| nr,Worked perfectly!! Many thanks.GC |
 |
|
|
|
|
|