dadamssg Posted January 30, 2009 Share Posted January 30, 2009 Im trying to set a query to select events that are gonna happen tomorrow...as in always the next day, the whole 24 hr period. i have the code below to query todays events, how can i set that up to query for tomorrow? $quer = "SELECT * FROM test WHERE DATE(start) <= CURDATE() AND DATE(end) >= CURDATE() ORDER BY start DESC"; I doubt theres a tomorrow date function like the curdate()...any help would be amazing, thanks Quote Link to comment https://forums.phpfreaks.com/topic/143195-solved-query-tomorrow/ Share on other sites More sharing options...
Mchl Posted January 30, 2009 Share Posted January 30, 2009 CURDATE() + 1 Quote Link to comment https://forums.phpfreaks.com/topic/143195-solved-query-tomorrow/#findComment-751016 Share on other sites More sharing options...
dadamssg Posted January 30, 2009 Author Share Posted January 30, 2009 wow, that simple? awesome thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/143195-solved-query-tomorrow/#findComment-751017 Share on other sites More sharing options...
Mchl Posted January 30, 2009 Share Posted January 30, 2009 emm... no... that returns silly results for the last day of month 20090132 Quote Link to comment https://forums.phpfreaks.com/topic/143195-solved-query-tomorrow/#findComment-751018 Share on other sites More sharing options...
Mchl Posted January 30, 2009 Share Posted January 30, 2009 try SELECT * FROM test WHERE DATEDIFF(start,CURDATE()) = 1 AND DATEDIFF(end,CURDATE()) = 1 ORDER BY start DESC Quote Link to comment https://forums.phpfreaks.com/topic/143195-solved-query-tomorrow/#findComment-751020 Share on other sites More sharing options...
dadamssg Posted January 30, 2009 Author Share Posted January 30, 2009 thanks i will as soon as my hosting service lets me login! Quote Link to comment https://forums.phpfreaks.com/topic/143195-solved-query-tomorrow/#findComment-751027 Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 worked beautifully thank you, i have a database full of events...start, end, title, and then event type(sports, music, etc.) how would i make that same query only pull up the event type of say music??? the column in the database is called eventtype Quote Link to comment https://forums.phpfreaks.com/topic/143195-solved-query-tomorrow/#findComment-751044 Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 ehh i take that back...it pulled up events starting and ending on tomorrows date but didn't pull up anything in between...ie an event that started yesterday and ended feb 2. anymore suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/143195-solved-query-tomorrow/#findComment-751125 Share on other sites More sharing options...
xtopolis Posted January 31, 2009 Share Posted January 31, 2009 SELECT * FROM test WHERE DATE(DATE_ADD(CURDATE(), INTERVAL 1 DAY)) BETWEEN DATE(start) AND DATE(end) AND eventtype = 'music' ORDER BY start DESC Theoretically this should pull up any events that are still going on / or starting as of tomorrow. I haven't tested this. Also, I'm fairly certain adding the DATE() function around the columns and current date is redundant, but perhaps it's necessary to pull the whole day as you said. If that doesn't work, let us know, and be more specific with what results you want to get back. Quote Link to comment https://forums.phpfreaks.com/topic/143195-solved-query-tomorrow/#findComment-751129 Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 well done xtopolis! thank you, finally works! Quote Link to comment https://forums.phpfreaks.com/topic/143195-solved-query-tomorrow/#findComment-751134 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.