Ansel_Tk1 Posted November 26, 2010 Share Posted November 26, 2010 Hi - wondering if someone out there can give me some guidance. I'm trying to select only those rows where my datetime field is less than or equal to 1 calendar day of todays date (not 24hrs). Basically, I am making a contest entry form where you can only enter the contest once every calendar day. This is what I am using now but the logic seems messed up: SELECT * FROM newssubscribe_details WHERE contestid = %s AND newssubscribe_id = %s AND dateandtime <= CURRENT_DATE() - INTERVAL 1 day Any help would be really appreciated! Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/219916-using-interval-to-select-within-date-range/ Share on other sites More sharing options...
fenway Posted November 26, 2010 Share Posted November 26, 2010 Assuming you can't travel in time, why not only select those rows that don't match today's date? Quote Link to comment https://forums.phpfreaks.com/topic/219916-using-interval-to-select-within-date-range/#findComment-1140120 Share on other sites More sharing options...
Ansel_Tk1 Posted November 27, 2010 Author Share Posted November 27, 2010 I love simple logic. That makes sense. Although I am trying this but need to work out how to specify the actual day (todays date): SELECT * FROM newssubscribe_details WHERE contestid = %s AND newssubscribe_id = %s AND dateandtime = DATE(NOW()) Quote Link to comment https://forums.phpfreaks.com/topic/219916-using-interval-to-select-within-date-range/#findComment-1140146 Share on other sites More sharing options...
Pikachu2000 Posted November 27, 2010 Share Posted November 27, 2010 AND dateandtime = CURDATE() Quote Link to comment https://forums.phpfreaks.com/topic/219916-using-interval-to-select-within-date-range/#findComment-1140147 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.