Am trying to fetch data from the database, for dates between two values. The fields in my database for the dates are under the DATE data type and are working for other operations. I calculate the date after one month from current date, and try to fetch a date value 'DateOfExpiry' between today's date and date after one month, using the following code..
Code: Select all
$query = "SELECT * FROM customer_info WHERE CustCategory = '$user_categ' AND DateOfExpiry BETWEEN '$today' AND '$next_month'";
$q = mysql_query($query);
if ( ! $q ) { die("Can't Fetch: " .mysql_error()); }I calculate $today and $next_month by,
Code: Select all
$today = date('Y-m-d');
$epoch_today = mktime(0,0,0,date('m'),date('d'),date('y'));
$epoch_next_month = mktime(0,0,0,date('m')+1,date('d'),date(y));
$next_month = strftime('%Y-%m-%d', $epoch_next_month);