chiprivers Posted October 5, 2011 Share Posted October 5, 2011 Please could somebody help me with this, I assume, pretty simple SQL where clause... I have a DATE column in my table (field is called reviewdate) and I would like to return all records where the value in this column is within the current month. Could somebody help with the WHERE clause? Something like... WHERE functionformonthandyearof(reviewdate) = functionforcurrentmonthandyear() Many thanks in advance. Quote Link to comment Share on other sites More sharing options...
awjudd Posted October 5, 2011 Share Posted October 5, 2011 Is this what you want? WHERE MONTH(reviewdate) = MONTH(CURDATE()) ~juddster Quote Link to comment Share on other sites More sharing options...
chiprivers Posted October 5, 2011 Author Share Posted October 5, 2011 That looks good but do I also need to specify the year also to ensure that it only returns entries with a matching month in the current year and not say all records with a review date in October every year? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 5, 2011 Share Posted October 5, 2011 WHERE EXTRACT(YEAR_MONTH FROM reviewdate) = EXTRACT(YEAR_MONTH FROM CURDATE()) Quote Link to comment Share on other sites More sharing options...
chiprivers Posted October 5, 2011 Author Share Posted October 5, 2011 thank you - that looks like it will work - will give it a go Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.