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 |
MTSPEER
Starting Member
6 Posts |
Posted - 2013-06-03 : 14:48:25
|
Hey guys, I have 3 fields I want to display. The name of the person[Name], Date Mailed[Date Mailed], and Date Received[Date Received]. I want to display the records that don't have information in them and only if it's been 30 days or more. I wrote this code here:Select * from Sheet1Where [Date Received] is NULL But that only returns all the blank fields. I want to display the ones that are blank and have been 30 days..I want to keep the blank records within the 30 day period. |
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2013-06-03 : 14:52:00
|
30 days check should be on DateMailed? If so you can have an other check as e.g. Select * from Sheet1Where [Date Received] is NULL AND DateMailed between dateadd(mm,-1,getdate()) and getdata()CheersMIK |
 |
|
MTSPEER
Starting Member
6 Posts |
Posted - 2013-06-03 : 14:56:43
|
It says Undefined function 'getdate' in the expression |
 |
|
MTSPEER
Starting Member
6 Posts |
Posted - 2013-06-03 : 14:58:21
|
BTW-I just want to display the blank records that are past the 30 day period of Date Mailed |
 |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-06-04 : 01:32:22
|
quote: Originally posted by MTSPEER It says Undefined function 'getdate' in the expression
-- Small typoSelect * from Sheet1Where [Date Received] is NULL AND DateMailed between dateadd(mm,-1,getdate()) and getdate()--Chandu |
 |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-06-04 : 01:40:42
|
quote: Originally posted by MTSPEER BTW-I just want to display the blank records that are past the 30 day period of Date Mailed
use this condition for past 30 days mailsWHERE [Date Mailed] > = DATEADD( DD, -30 , DATEDIFF(DD, 0, GETDATE()))--Chandu |
 |
|
|
|
|