guyfromfl Posted March 30, 2011 Share Posted March 30, 2011 Does anybody know how to do something like: SELECT * FROM tbl WHERE insertDate IS BETWEEN NOW AND LAST THURSDAY Quote Link to comment https://forums.phpfreaks.com/topic/232127-selecting-everything-between-now-and-last-thursday/ Share on other sites More sharing options...
guyfromfl Posted March 30, 2011 Author Share Posted March 30, 2011 For other inquiring minds: SELECT * FROM tabl WHERE dateField >= CONCAT( DATE_SUB(CURDATE(), INTERVAL WEEKDAY(DATE_SUB(CURDATE(), INTERVAL 5 DAY)) DAY), ' 00:00:00'); Then change the interval number to whatever day of the week you want. Quote Link to comment https://forums.phpfreaks.com/topic/232127-selecting-everything-between-now-and-last-thursday/#findComment-1194050 Share on other sites More sharing options...
gizmola Posted March 30, 2011 Share Posted March 30, 2011 I wrote an article about a very similar subject: http://www.gizmola.com/blog/archives/99-Finding-Next-Monday-using-MySQL-Dates.html Quote Link to comment https://forums.phpfreaks.com/topic/232127-selecting-everything-between-now-and-last-thursday/#findComment-1194196 Share on other sites More sharing options...
guyfromfl Posted March 30, 2011 Author Share Posted March 30, 2011 That article is AWSOME. Perfect for what I want to do. I just need to go backwards! WAY cleaner than my solution. Thanks a million! Quote Link to comment https://forums.phpfreaks.com/topic/232127-selecting-everything-between-now-and-last-thursday/#findComment-1194357 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.