savj14 Posted March 28, 2008 Share Posted March 28, 2008 Ok so I have some events in my Mysql Database and I want to sort them, but I just can't get it to sort correctly. In the database I have event_date_start and event_date_end. I'd like to be able to sort by event_date_start which isn't the problem. The problem is I want to include only events from today's date or later, not earlier. I hope that makes sense. I have tried <,>,<=,>= with no luck....I assume I have to somehow take only the portion of event_date_start that holds the day and compare to that but I have no idea how to go about that. Here is the code I am using......Hopefully someone can help me. $where = "(event_date_start>'".time()."')"; The code to sort the Events: $events = $event->event_list(0, 5, "event_date_start ASC", $where, 1); Since the event_date_start is stored in the Data base as 1206493200 for example, I am not sure how to just compare the day. Please help. Link to comment https://forums.phpfreaks.com/topic/98247-comparing-time/ Share on other sites More sharing options...
asaschool Posted March 28, 2008 Share Posted March 28, 2008 I do this same thing by setting a query for every week I want to show data for. I do this by using the following sql for each week and adjusting the dates to match my needs: SELECT what you need FROM where it is WHERE date_one BETWEEN curdate()+7 AND curdate()+14 The above sql give me data that is from next Thursday to the following Wednesday (7 days from today to 14 days from today.) Hope this helps Link to comment https://forums.phpfreaks.com/topic/98247-comparing-time/#findComment-502703 Share on other sites More sharing options...
doni49 Posted March 28, 2008 Share Posted March 28, 2008 I'm pretty sure it's one of these. $where = "event_date_start > time()"; or $where = "`event_date_start` > time()"; Link to comment https://forums.phpfreaks.com/topic/98247-comparing-time/#findComment-502717 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.