Hi Everyone Grin
I have a form where people can select two dates, $date1 and $date2. I have the WHERE statement set so it's greater or equal to, and lesser or equal to.
My Issue:
When I select a date from $date1 it works fine. But when I select a date from $date2 it gives me the entire year. So if I select June 15th, 2000 through June 1st, 2007, it echos the results from
June 15th, 2000 through December 31st, 2007.
Here is MySQL query code:
//Define the Date Range
function date_range() {
$date1 = $_POST['year1'] . $_POST['day1'] . $_POST['month1'];
$date2 = $_POST['year2'] . $_POST['day2'] . $_POST['month2'];
echo "<br>You selected: " . $_POST['month1'] . " " . $_POST['day1'] . " " . $_POST['year1'] . " through "
. $_POST['month2'] . " " . $_POST['day2'] . " " . $_POST['year2'] . "";
require ('get_connected.php');
$sql = "SELECT * FROM canada WHERE `letter_requested` >= '"
. $date1 .
"' AND `letter_requested` <='"
. $date2 . "'";
Does someone know how to rectify this? The BETWEEN command only gives me dates between, I would like the result to include the date selected.
Thanks!
SC