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 |
|
Rawager
Starting Member
2 Posts |
Posted - 2003-01-24 : 12:14:39
|
| I need to pull records based on Dates.Example.IF Today is between 1 and 15 then pull records dated within a specific date range Else records dated within another date range.This condition needs to be validated along with other conditions in the WHERE clause. Any thoughts?......R |
|
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
Posted - 2003-01-24 : 12:37:07
|
| WHERE(Day(getdate()) < = 15 AND mydate between startdate and enddate) OR(Day(getdate()) > 15 AND mydate between startdate and enddate |
 |
|
|
Juls
Yak Posting Veteran
51 Posts |
Posted - 2003-01-24 : 12:40:19
|
| You can build a dynamic WHERE clause and do if else statement and attaching correct dates to WHERE.DECLARE @WHERe varchar(4000)SET @WHERE = 'WHERE 'If datepart(dd,getdate())>=1 and datepart(dd,getdate())<=15 SET @WHERE = @WHERE + 'mydate between Date1 and Date2'Something like above |
 |
|
|
Rawager
Starting Member
2 Posts |
Posted - 2003-01-24 : 14:54:51
|
| Thank you guys. That gave me few more ideas to try out.......R |
 |
|
|
|
|
|