chelnov63 Posted March 18, 2009 Share Posted March 18, 2009 I have a database table called concerts and one of the fields is a date field called concert_date which holds the date in the format: YYYY-MM-DD Now in on one of the php pages i want to show (in three different tables): all concerts which are today.. all concerts which are tommorow all concerts which are within a week... i've started off like this: $today = date("Y")."-".date("m")."-".date("d"); $tommorow = ?????; $within_a_week = ???? //query for concerts today $result_today = mysql_query("SELECT * FROM concerts WHERE concert_date = '$today'"); but how do i get the results for tommorow and for concerts within a week (excluding today and tommorow) thanks in advance for you help Link to comment https://forums.phpfreaks.com/topic/149985-comparing-dates/ Share on other sites More sharing options...
Ayon Posted March 18, 2009 Share Posted March 18, 2009 you would try this <?php $unix['day'] = strtotime("+1 day"); $unix['week'] = strtotime("+1 week"); $tomorrow = date("Y-m-d", $unix['day']); $within_a_week = date("Y-m-d", $unix['week']); $result_today = mysql_query("SELECT * FROM concerts WHERE concert_date = '$today'"); $result_tomorrow = mysql_query("SELECT * FROM concerts WHERE concert_date = '$tomorrow"); $result_week = mysql_query("SELECT * FROM concerts WHERE concert_date <= '$today'" OR concert_date >= '$within_a_week'); ?> havent tried the sql.. but i know the php returns the right date Link to comment https://forums.phpfreaks.com/topic/149985-comparing-dates/#findComment-787700 Share on other sites More sharing options...
chelnov63 Posted March 18, 2009 Author Share Posted March 18, 2009 awesome..works great thanks for your help mate!!! appreciate it Link to comment https://forums.phpfreaks.com/topic/149985-comparing-dates/#findComment-787713 Share on other sites More sharing options...
Ayon Posted March 18, 2009 Share Posted March 18, 2009 no problem Link to comment https://forums.phpfreaks.com/topic/149985-comparing-dates/#findComment-787717 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.