dadamssg Posted January 31, 2009 Share Posted January 31, 2009 This query pulls up events that are all happening today, 24hr period. how do i turn this into always pull up tomorrows? SELECT * FROM test WHERE DATE(start) <= CURDATE() AND DATE(end) >= CURDATE() ORDER BY start DESC Quote Link to comment https://forums.phpfreaks.com/topic/143301-help/ Share on other sites More sharing options...
Snart Posted January 31, 2009 Share Posted January 31, 2009 CURDATE() + 1 should add a day. Quote Link to comment https://forums.phpfreaks.com/topic/143301-help/#findComment-751569 Share on other sites More sharing options...
Chicken Little Posted January 31, 2009 Share Posted January 31, 2009 Assuming your table has a date field (here called date_created) you can use SELECT * FROM test WHERE DATE(date_created) >= DATE_ADD( CURDATE( ) , INTERVAL +1 DAY) ORDER BY date_created DESC Quote Link to comment https://forums.phpfreaks.com/topic/143301-help/#findComment-751579 Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 what exactly does the curdate() function output? maybe i just play around with the right format ill get somewhere because my table has a created, start, and end fields...so im tryin to select the ones that going on tomorrow according to the start and end fields..if that makes sense... Quote Link to comment https://forums.phpfreaks.com/topic/143301-help/#findComment-751584 Share on other sites More sharing options...
Chicken Little Posted January 31, 2009 Share Posted January 31, 2009 Ok. If your field is called end you can use SELECT * FROM test WHERE DATE( end ) = DATE_ADD( CURDATE() , INTERVAL +1 DAY ) ORDER BY end DESC Quote Link to comment https://forums.phpfreaks.com/topic/143301-help/#findComment-751601 Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 worked perfect thank you...and im gonna create a selection list for the user to select a date and then pull up everything thats goin on on that date...what date format does sql understand? cause i tried (2009-02-02) and (2009-02-02 00:00:00) and although both of those didn't get an error, they didn't select anything... Quote Link to comment https://forums.phpfreaks.com/topic/143301-help/#findComment-751606 Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 take that back...cause some of my events last for days, say jan 31 to feb 5...and that query won't pull of that event...the query has to be based on the start and end datetime... Quote Link to comment https://forums.phpfreaks.com/topic/143301-help/#findComment-751611 Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 haha i don't know if im talkin to myself but i modified chicken littles request to below and it works, but i still want to know the format CURDATE() is so i can use that for my date selection list. SELECT * FROM test WHERE DATE(start) <= DATE_ADD( CURDATE(), INTERVAL+1 DAY) AND DATE(end) >= DATE_ADD( CURDATE(), INTERVAL +1 DAY) ORDER BY start DESC Quote Link to comment https://forums.phpfreaks.com/topic/143301-help/#findComment-751612 Share on other sites More sharing options...
fenway Posted February 2, 2009 Share Posted February 2, 2009 Then use DATE_FORMAT(). And CURDATE()+1 is pure evil, use CURDATE()+INTERVAL 1 DAY. Quote Link to comment https://forums.phpfreaks.com/topic/143301-help/#findComment-752457 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.