dadamssg Posted March 1, 2009 Share Posted March 1, 2009 how do you query tomorrow? as in this will query todays date SELECT * FROM test WHERE DATE(start) <= CURDATE() AND DATE(end) >= CURDATE() i know theres somethin like CURDATE(interval + 1 day)...i know thats not it, but somethin similar is our there i know Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/ Share on other sites More sharing options...
corbin Posted March 1, 2009 Share Posted March 1, 2009 http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html is your friend. DATE_ADD(CURDATE(), INTERVAL 1 DAYS) Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-774101 Share on other sites More sharing options...
dadamssg Posted March 1, 2009 Author Share Posted March 1, 2009 awesome thanks, but how do i make this work? SELECT * FROM test WHERE start <= DATE_ADD(CURDATE(), INTERVAL 1 DAYS) AND end >= DATE_ADD(CURDATE(), INTERVAL 1 DAYS) ORDER BY start ASC Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-774115 Share on other sites More sharing options...
dadamssg Posted March 2, 2009 Author Share Posted March 2, 2009 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-774231 Share on other sites More sharing options...
fenway Posted March 2, 2009 Share Posted March 2, 2009 DAY -- singular; checking mysql_error() and the refman would have told you that. N.B. you've now started 3 threads on basically the same topic... I would caution you against starting another one when there are existing threads to continue. Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-774400 Share on other sites More sharing options...
corbin Posted March 2, 2009 Share Posted March 2, 2009 Ahhh didn't see this thread. DAY, not DAYS? Damn..... ;p I would've thought DAYS would work since what if it had been like 3 DAYS. Or would it still have been DAY? INTERVAL 3 DAY would bug me forever. Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-774420 Share on other sites More sharing options...
fenway Posted March 2, 2009 Share Posted March 2, 2009 Well, if zero can be plural..... Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-774538 Share on other sites More sharing options...
corbin Posted March 2, 2009 Share Posted March 2, 2009 >.< Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-774585 Share on other sites More sharing options...
dadamssg Posted March 3, 2009 Author Share Posted March 3, 2009 k this isn't really the same as querying tom, but im trying not to open any new threads anyways....im trying to query today...i thought i had it. I want to query everything going on today, whether its starting, ending, or today lands in between start and end. this is what i have which almost works... SELECT * FROM test WHERE start <= NOW() AND end >= NOW() ORDER BY start ASC it does not, however, pull up events that are happenning today but haven't started yet, examples below i queried this at 12:50 pm and it pulled up id start end 88 | 2/4/2009 1:00pm | 3/4/2009 1:00pm 85 | 3/1/2009 1:00pm | 3/3/2009 2:00pm 98 | 3/4/2009 1:00am | 3/6/2009 9:30pm 104 | 3/3/2009 1:00am | 3/3/2009 4:00pm all these are correct BUT i also had the following in the database that it did NOT pull up id start end 103 | 3/3/2009 1:00pm | 3/3/2009 7:00pm 105 | 3/3/2009 2:00pm | 3/3/2009 7:00pm it didn't because 'start <= NOW()' but i don't really now what to replace this part with oh and then when i queried at 1:10pm it pulled up event #103 of course REAL LONG post but help would be MUCH appreciated thanks Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-775874 Share on other sites More sharing options...
dadamssg Posted March 4, 2009 Author Share Posted March 4, 2009 plllllleeeeeaaaseee??? Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-776130 Share on other sites More sharing options...
fenway Posted March 4, 2009 Share Posted March 4, 2009 Why not NOW() BETWEEN start AND end ? (obviously, it's better to expand that for index usage ) Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-776210 Share on other sites More sharing options...
dadamssg Posted March 4, 2009 Author Share Posted March 4, 2009 i LOVE new perspectives, thanks man. question though...is this the same as what you suggested? SELECT * FROM test WHERE DATE(start) <= CURDATE() AND end > NOW() Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-776298 Share on other sites More sharing options...
fenway Posted March 4, 2009 Share Posted March 4, 2009 No, that's the opposite... and why are you mixing curdate and now? Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-776429 Share on other sites More sharing options...
dadamssg Posted March 4, 2009 Author Share Posted March 4, 2009 how is that the opposite? im using curdate() and now() because i am storing events that have start and end datetimes and i don't want to pull up events that have already ended Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-776485 Share on other sites More sharing options...
fenway Posted March 4, 2009 Share Posted March 4, 2009 Sorry, going cross-eyed today, that looks fine -- I still don't see why you can't directly compare NOW() to start, though. Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-776682 Share on other sites More sharing options...
dadamssg Posted March 4, 2009 Author Share Posted March 4, 2009 its because if i compare now() to start and the event starts today at 9:00pm and its 4:30 right now it won't show if start <=NOW() Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-776750 Share on other sites More sharing options...
fenway Posted March 9, 2009 Share Posted March 9, 2009 its because if i compare now() to start and the event starts today at 9:00pm and its 4:30 right now it won't show if start <=NOW() right. Quote Link to comment https://forums.phpfreaks.com/topic/147468-query-tomorrow/#findComment-780137 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.