peddel Posted August 20, 2008 Share Posted August 20, 2008 I got a MySQL table with some collums, the important collums are the following : DAY - MONTH - YEAR - HOUR - MINUTE The filling of this collums happens by using a date object and splitting it into the right sections. I got a form with 6 drop down boxes for a person to select a start and a ending date. Start boxes : DAY - MONTH - YEAR End boxes: DAY - MONTH - YEAR Now i want to find all the records in my table between these 2 dates. Someone suggested me to use the following code SELECT * FROM `dt_tb` WHERE dt BETWEEN '2005-01-01' AND '2005-12-31' Problem here is that i splitted the information, so its kinda hard to use that code. Can anyone help out? Link to comment https://forums.phpfreaks.com/topic/120488-solved-help-on-mysql-and-selection-by-dates/ Share on other sites More sharing options...
peddel Posted August 20, 2008 Author Share Posted August 20, 2008 Again after some long testing i found a sollution And its rather easy, just a evolved version of what they suggested me. $sql = "SELECT * FROM $register WHERE dag BETWEEN '$dagB' AND '$dagE' AND maand BETWEEN '$maandB' AND '$maandE' AND jaar BETWEEN '$jaarB' AND '$jaarE'"; Link to comment https://forums.phpfreaks.com/topic/120488-solved-help-on-mysql-and-selection-by-dates/#findComment-620894 Share on other sites More sharing options...
fenway Posted August 20, 2008 Share Posted August 20, 2008 "Split the information"? I really hope you're not storing the date as three separate fields.... Link to comment https://forums.phpfreaks.com/topic/120488-solved-help-on-mysql-and-selection-by-dates/#findComment-621006 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.