just me and php Posted February 1, 2007 Share Posted February 1, 2007 This Works But Echo's All Dates Posted And I Only Want 2 Weeks Between Dates $start = strtotime("01/27/07 23:59:59"); $end = strtotime("02/11/07 23:59:59"); $p_id1 = 'Danger Zone'; $query = "SELECT DATE_FORMAT(date, '%h:%i %p') AS time, recno,disp,track,Username,MAX(date) AS date,online, MIN(HL_MS) AS HL_MS,reshack,hacked FROM NatHotLap WHERE track= '$p_id1' GROUP BY 'disp','online','Username','track' ORDER BY 'HL_MS' ASC "; This One Below Doesnt Work Because Of WHERE date BETWEEN '$start' AND '$end ',track= '$p_id1' How Can I Make This Work??? date and track are rows in my table $start = strtotime("01/27/07 23:59:59"); $end = strtotime("02/11/07 23:59:59"); $p_id1 = 'Danger Zone'; $query = "SELECT DATE_FORMAT(date, '%h:%i %p') AS time, recno,disp,track,Username,MAX(date) AS date,online, MIN(HL_MS) AS HL_MS,reshack,hacked FROM NatHotLap WHERE date BETWEEN '$start' AND '$end ',track= '$p_id1' GROUP BY 'disp','online','Username','track' ORDER BY 'HL_MS' ASC "; Link to comment https://forums.phpfreaks.com/topic/36575-how-can-i-do-this-please-help/ Share on other sites More sharing options...
pocobueno1388 Posted February 1, 2007 Share Posted February 1, 2007 You might want to change your row called "date" to something else. Date is a set PHP expression and it will get confused. So change that first then see if it works. Link to comment https://forums.phpfreaks.com/topic/36575-how-can-i-do-this-please-help/#findComment-174191 Share on other sites More sharing options...
Jessica Posted February 1, 2007 Share Posted February 1, 2007 It is possible to use syntax like this: "SELECT * FROM table WHERE field > '2007-01-27 23:59:59' AND field < '2007-02-11 23:59:59'"; Just format your strings the same as the mysql datetime field and this should work. Plus what poco said. Link to comment https://forums.phpfreaks.com/topic/36575-how-can-i-do-this-please-help/#findComment-174192 Share on other sites More sharing options...
just me and php Posted February 1, 2007 Author Share Posted February 1, 2007 i dont understand this could you explain please Just format your strings the same as the mysql datetime field and this should work. Link to comment https://forums.phpfreaks.com/topic/36575-how-can-i-do-this-please-help/#findComment-174193 Share on other sites More sharing options...
Jessica Posted February 1, 2007 Share Posted February 1, 2007 I don't know how I could explain it when I already wrote it out for you. Just change the table name and row names to yours. Link to comment https://forums.phpfreaks.com/topic/36575-how-can-i-do-this-please-help/#findComment-174199 Share on other sites More sharing options...
just me and php Posted February 1, 2007 Author Share Posted February 1, 2007 thanks i changed date row in table to tbldate and this WHERE tbldate > '01/27/07 23:59:59' AND tbldate < '02/11/07 23:59:59' and it posted all data in the date time i wanted. but i also need it to post this WHERE track= '$p_id1' how can i add that in the WHERE tbldate > '01/27/07 23:59:59' AND tbldate < '02/11/07 23:59:59' Link to comment https://forums.phpfreaks.com/topic/36575-how-can-i-do-this-please-help/#findComment-174250 Share on other sites More sharing options...
Jessica Posted February 1, 2007 Share Posted February 1, 2007 No, you have to format them the way I posted. It's YYYY-MM-DD HH:ii:ss. 2007-01-27 23:59:59 not 02/11/07 23:59:59 just add another AND on the end. Link to comment https://forums.phpfreaks.com/topic/36575-how-can-i-do-this-please-help/#findComment-174254 Share on other sites More sharing options...
just me and php Posted February 1, 2007 Author Share Posted February 1, 2007 Thank You ,Thank You ,Thank You ,I Been Trying To Do This For Months And Even Hired A PHP Guro Who Couldnt Figure It Out. It WORKS GREAT :) Link to comment https://forums.phpfreaks.com/topic/36575-how-can-i-do-this-please-help/#findComment-174260 Share on other sites More sharing options...
Jessica Posted February 1, 2007 Share Posted February 1, 2007 Get your money back. Link to comment https://forums.phpfreaks.com/topic/36575-how-can-i-do-this-please-help/#findComment-174262 Share on other sites More sharing options...
dgiberson Posted February 1, 2007 Share Posted February 1, 2007 hahaha, nice one jesirose.... was thinking that myself Link to comment https://forums.phpfreaks.com/topic/36575-how-can-i-do-this-please-help/#findComment-174278 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.