MySQL Forums
Forum List  »  Newbie

Query Question
Posted by: Ken Darington
Date: March 25, 2009 04:14PM

I'm trying a query that will return all of the results for the previous dates excluding the current month of the current year.

Currently i'm using...

SELECT * FROM `register` WHERE year(date)+month(date) < year(curdate())+month(curdate())

This appears to work when I look at my results, but I dont know if this is actually working how I want it to. Is this combining the year and month and comparing it to the current year and month?

I'm worried its taking the year 2009 adding it with 03 and then comparing that to other entries like 2008+03 which means a date like 2005+12 would be higher and not show up.

Is this the best way to accomplish getting all the results for all months but the current month?


Options: ReplyQuote

Written By
Query Question
March 25, 2009 04:14PM
March 25, 2009 06:12PM
March 26, 2009 11:59PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.