tomhoad Posted May 17, 2009 Share Posted May 17, 2009 Hi, My query for an events page is as follows: $query = "SELECT id, venue, FROM_UNIXTIME(date, '%d/%m/%Y') as dttm, tickets FROM events WHERE date >= NOW() ORDER BY date"; But it returns nothing at all (no errors though). How can I get it to only select the gigs from todays date (i.e. not displaying past gigs). Simple I'm sure, but I'm inexperienced! Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/158486-solved-only-displaying-after-the-current-date/ Share on other sites More sharing options...
gregor171 Posted May 18, 2009 Share Posted May 18, 2009 WHERE date >= NOW() Would show all the dates in the future and NOW (at this moment). WHERE date <= NOW() Quote Link to comment https://forums.phpfreaks.com/topic/158486-solved-only-displaying-after-the-current-date/#findComment-836138 Share on other sites More sharing options...
Ken2k7 Posted May 18, 2009 Share Posted May 18, 2009 $query = "SELECT id, venue, FROM_UNIXTIME(date, '%d/%m/%Y') as dttm, tickets FROM events WHERE TIME_FORMAT(date, '%Y-%m-%d') = CURDATE() ORDER BY date"; Quote Link to comment https://forums.phpfreaks.com/topic/158486-solved-only-displaying-after-the-current-date/#findComment-836175 Share on other sites More sharing options...
tomhoad Posted May 18, 2009 Author Share Posted May 18, 2009 Thanks for the replies! Neither quite worked, but pointed me in the right direction. For future reference: $query = "SELECT id, venue, FROM_UNIXTIME(date, '%d/%m/%Y') as dttm, tickets FROM events WHERE FROM_UNIXTIME(date, '%Y-%m-%d') > CURDATE() ORDER BY date"; Quote Link to comment https://forums.phpfreaks.com/topic/158486-solved-only-displaying-after-the-current-date/#findComment-836282 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.