Mysql Between Date range help in where clause

Hi Experts

I am trying to do a query where I can take the date now and look at data for the next 3 months
I keep getting a syntax error and am not sure if I am doing the query correct.

What is the correct way of doingthis query?

Thanks
WHERE
	theme_keyword_promotiontracker2.TK_profileid = 131
AND theme_keyword_promotiontracker2.number > 0
AND theme_keyword_promotiontracker2.PP_dateDue 
BETWEEN 
MONTH(theme_keyword_promotiontracker2.PP_dateDue)= MONTH(NOW()) AND 
MONTH(theme_keyword_promotiontracker2.PP_dateDue)= MONTH(DATE_ADD(NOW(), INTERVAL 3 MONTH))

Open in new window

matthewdacruzAsked:
Who is Participating?
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.

johanntagleCommented:
Try:

BETWEEN MONTH(NOW()) AND MONTH(DATE_ADD(NOW(), INTERVAL 3 MONTH))
0
johanntagleCommented:
BETWEEN clause just has:

BETWEEN <start value> AND <end value>.

To complete your solution, it should be:

AND month(theme_keyword_promotiontracker2.PP_dateDue)
BETWEEN MONTH(NOW()) AND MONTH(DATE_ADD(NOW(), INTERVAL 3 MONTH))
0

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
matthewdacruzAuthor Commented:
Thanks fro the help.
If I wanted to have the end part of the between to be for the last month of the current year do I just add YEAR(NOW() instead of Interval...
0
johanntagleCommented:
No.  In the previous SQL we were comparing months.  Year(now()) will return the 2011 so its not correct comparison.  Pls read up on the usage of the time and date functions before you use them.  Anyway it should be something like:

between month(now()) and 12
And year(theme_keyword_promotiontracker2.PP_dateDue)=year(now())
0
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
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.