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 |
|
Topaz
Posting Yak Master
199 Posts |
Posted - 2008-06-02 : 09:42:28
|
| SELECT websiteFROM dbo.wce_contactWHERE (NOT (Mail1Date IS NULL)) AND (Mail2Date IS NULL) AND (Mail3Date IS NULL) AND (Mail4Date IS NULL) AND (Mail5Date IS NULL) AND (Mail6Date IS NULL) AND (Mail7Date IS NULL) AND (Mail8Date IS NULL) AND (Mail9Date IS NULL) AND (Mail10Date IS NULL) AND (Mail11Date IS NULL) AND (Mail12Date IS NULL)AND (Mail13Date IS NULL) AND (Mail14Date IS NULL) AND (Mail15Date IS NULL) AND (Mail16Date IS NULL) AND (IDStatus IS NULL OR IDStatus = '') AND (NOT (Task LIKE '%x%') OR Task IS NULL) AND (NOT (ExpressEmail IS NULL OR ExpressEmail = '')) AND (NOT (WebSite IS NULL OR WebSite = '')) AND (Mail17Date IS NULL OR Mail17Date = '') AND (Mail18Date IS NULL) AND (Mail1Date <= '20080421') AND (NOT (RECORDOWNER = 'lbm') OR RECORDOWNER IS NULL)How would i get the part in red to say mail1date less than or equal to 42 days back from todays date? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-02 : 09:47:43
|
| Have a look at DATEADD() function and GETDATE() function in books online. |
 |
|
|
Topaz
Posting Yak Master
199 Posts |
Posted - 2008-06-02 : 09:49:16
|
| I hate using BOL, never once have i managed to understand it... |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-06-02 : 09:51:14
|
quote: Originally posted by Topaz SELECT websiteFROM dbo.wce_contactWHERE (NOT (Mail1Date IS NULL)) AND (Mail2Date IS NULL) AND (Mail3Date IS NULL) AND (Mail4Date IS NULL) AND (Mail5Date IS NULL) AND (Mail6Date IS NULL) AND (Mail7Date IS NULL) AND (Mail8Date IS NULL) AND (Mail9Date IS NULL) AND (Mail10Date IS NULL) AND (Mail11Date IS NULL) AND (Mail12Date IS NULL)AND (Mail13Date IS NULL) AND (Mail14Date IS NULL) AND (Mail15Date IS NULL) AND (Mail16Date IS NULL) AND (IDStatus IS NULL OR IDStatus = '') AND (NOT (Task LIKE '%x%') OR Task IS NULL) AND (NOT (ExpressEmail IS NULL OR ExpressEmail = '')) AND (NOT (WebSite IS NULL OR WebSite = '')) AND (Mail17Date IS NULL OR Mail17Date = '') AND (Mail18Date IS NULL) AND (Mail1Date <= '20080421') AND (NOT (RECORDOWNER = 'lbm') OR RECORDOWNER IS NULL)How would i get the part in red to say mail1date less than or equal to 42 days back from todays date?
AND ( MailDate <= DATEADD(DD,-42,GETDATE())) |
 |
|
|
Topaz
Posting Yak Master
199 Posts |
Posted - 2008-06-02 : 09:52:22
|
| nice work thanks!!! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-02 : 09:56:12
|
quote: Originally posted by Topaz I hate using BOL, never once have i managed to understand it...
May be because you're always being spoon feeded with answers. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|