I am unable to solve this and request help.
I have a Table in MySQL with Date field and date is in format (2011-08-12)
I wish to run query to get me result only where Current Date - 3 Days = Date in Database column
I use this query :
SELECT * FROM table WHERE date_booked <= CURRENT_DATE AND date_booked >= ( CURRENT_DATE - INTERVAL 3 DAY )
This does not give me data of query data of 2011-08-12 if today is 15th Aug that is 3 days ago.
When I run this it gives me data of today !
Below is my code :
<?php
error_reporting(-1);
ini_set(‘display_errors’, true);
include_once “connect_to_mysql.php”;
$sql = mysql_query(“SELECT * FROM dtdctri WHERE date_booked <= CURRENT_DATE AND date_booked >= ( CURRENT_DATE - INTERVAL 3 DAY )”);
echo “<table border=‘1’>
<tr>
<th>Shipping Number</th>
<th>Sender Name</th>
<th>Sender Email</th>
<th>Date Entered</th>
<th>Date Booked</th>
</tr>”;
while($row = mysql_fetch_array($sql)) {
echo “<tr>”;
echo “<td>” . $row[‘shpngnumber’] . “</td>”;
echo “<td>” . $row[‘sendername’] . “</td>”;
echo “<td>” . $row[‘email’] . “</td>”;
echo “<td>” . $row[‘date_entered’] . “</td>”;
echo “<td>” . $row[‘date_booked’] . “</td>”;
echo “</tr>”;
}
echo “</table>”;
?>
Thanks in advance