verify records with WHERE clauses to send emails on 2 seperate selected date fields

sql server 2008
What I'm trying to do: Looking to see if my sql statement is correct

I need properly read this sql statement and send emails out when the WHERE CLAUSE KICKS IN for a certain date reached.
On a 30 60 90 120 intervals

On the first WHERE clause:
The emails will be sent 30 less than the date_proposal_completed to current date.
Looking at any rows less than 30 days from todays date where "wl_status"    IS NULL.

When i send these emails out the "wl_status" gets updated to "emailed30"
AND then a field called "wl_emailed_on" gets updated to the date the email for "emailed30" was sent on. which would be the current date

What i need to happen in the next "OR" part of the WHERE clause

Is send another email only if  60 days from the "wl_emailed_on" to current date
reaches 60 days

example: data
wl_emailed_on                  wl_survey_completed_on                  wl_status
11/19/2015 8:57:58 AM                        NULL                        emailed30   <---- for 60 days this would NOT qualify
9/10/2015 8:57:58 AM                              NULL                        emailed30   <---- for 60 days this WOULD qualify

   proposal_id, specialist_responsible, customer_name, date_proposal_completed, seller_racf_id, 
   seller_email, wl_emailed_on, wl_survey_completed_on, wl_status, wl_Q1_answer, 
   wl_Q2_answer, wl_Q3_answer, wl_Feedback, wl_ReasonLoss
FROM temp_proposal_survey_results
DATEDIFF(day, date_proposal_completed, GETDATE()) <= 30 
   AND wl_status IS NULL
DATEDIFF(day, wl_emailed_on, GETDATE()) >= 60
AND  wl_status = 'emailed30' AND wl_survey_completed_on IS NULL

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

satish maddelaCommented:
Holds good. The OR is not properly braced. Just separate the first and second parts of the OR.
(DATEDIFF(day, date_proposal_completed, GETDATE()) <= 30
   AND wl_status IS NULL)
(DATEDIFF(day, wl_emailed_on, GETDATE()) >= 60
AND  wl_status = 'emailed30' AND wl_survey_completed_on IS NULL)

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FordraidersAuthor Commented:
so my statement of proposal fits the sql logic ?
FordraidersAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.