Its late and Im spinning my wheels here.
I am trying to get the returned list of rows to be very specific and I am having troubl with the mysql where clause.
$gstrSQL = "select `purchases`.`customer_id`, `purchases`.`purchase_id`, `purchases`.`group`, `purchases`.`inventory_id`, `purchases`.`purchase_date`, `purchases`.`price_subtotal`, `purchases`.`total`, `inventory`.`months` , `customer`.`name`, `customer`.`status_id` From `purchases`, `inventory`, `customer` WHERE ( (`price_subtotal` != 0) AND (`inventory`.`inventory_id` = `purchases`.`inventory_id`) AND (((`purchase_date` <= '".$_SESSION["company_year_end"]."')) AND ( (DATE_ADD('".`purchases`.`purchase_date`".', + INTERVAL (`inventory`.`months`) MONTHS)))>= now() ) ) AND (`customer`.`customer_id` = `purchases`.`customer_id`)AND (`customer`.`status_id` = 2) )";
The above query is generated in the variables.php file.
All is working except for one piece,
AND (((`purchase_date` <= '".$_SESSION["company_year_end"]."')) AND ( (DATE_ADD('".`purchases`.`purchase_date`".', + INTERVAL (`inventory`.`months`) MONTHS)))>= now() ) )
Im testing the purchase_date is less than the company year end, which works but the next AND where I am adding the number of months of the purchase to the purchase date to see if it is less than or equal to today.
If it is less than now() then the subscription has expired and I dont need it listed in the report.
Can someone point me to the error in my AND clause or am I completely off base. I have tried many many combinations, with quotes, without etc etc etc.