Ninjakreborn Posted September 11, 2010 Share Posted September 11, 2010 <?php $date = date('Y-m-d'); $strtime = strtotime('today +14 days'); $strtime = date('Y-m-d', $strtime); if ($distributor != 1) { $select = "SELECT deal_data.headline AS headline FROM deal_data WHERE str_to_date(deal_data.end_date,'%Y/%m/%d') BETWEEN str_to_date('" . $date . "', '%Y/%m/%d') and str_to_date('" . $strtime . "', '%Y/%m/%d')"; }else { $select = "SELECT deal_data.headline AS headline FROM deal_data WHERE str_to_date(deal_data.end_date,'%d.%m.%Y') BETWEEN '" . $date . "' and '" . $strtime . "'"; } ?> The dates are formatted in the database as Varchar (I don't do that anymore, this is an old project) and are formatted as: "09/12/2010". Anything wrong with the above code that would make it not work and return queries? Link to comment https://forums.phpfreaks.com/topic/213164-php-wmysql-dates/ Share on other sites More sharing options...
Ninjakreborn Posted September 11, 2010 Author Share Posted September 11, 2010 Nevermind, my date formatting was off. Should have been m/d/Y. I adjusted those in the query and it started working fine. Link to comment https://forums.phpfreaks.com/topic/213164-php-wmysql-dates/#findComment-1109975 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.