otuatail Posted June 22, 2015 Share Posted June 22, 2015 Hi I have to show all records over selected periods Last 6 months 2015 2014 2013 Before 2013 The first is easy WHERE LastVisit > DATE_ADD(CURRDATE, INTERVAL -6 MONTH I am finding the others harder. If I have to extract the year it could be a slow query. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted June 22, 2015 Share Posted June 22, 2015 the WHERE clause would be - WHERE YEAR(LastVisit) = whatever_year_value_you_want i'm pretty sure this would have the same level of performance as your Last 6 months query. Quote Link to comment Share on other sites More sharing options...
Barand Posted June 22, 2015 Share Posted June 22, 2015 (edited) WHERE lastvisit BETWEEN '2015-01-01' AND '2015-12-31' would use the index (assuming there is one on the lastvisit column) and therefore much faster Edited June 22, 2015 by Barand 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.