Hello all. I am hoping someone can help with a problem I am having. I need to pull all work orders from a table (which has a receipt date and a complete date) that were 45 days old during a given month and year. I have tried a couple of different things but I cannot wrap my head around this one.
My last attempt looks like this :
SELECT * FROM `table` WHERE
complete IS NULL AND DATE_ADD(receipt,INTERVAL 45 DAY) BETWEEN '$xyear-$xmonth-01' AND '$xyear-$xmonth-$xday'
OR complete > DATE_ADD(receipt,INTERVAL 45 DAY) AND
DATE_ADD(receipt,INTERVAL 45 DAY) BETWEEN '$xyear-$xmonth-01' AND '$xyear-$xmonth-$xday'
$xyear and $xmonth are inputs from a form and $xday is calculated on the fly depending on the days in the given month. This almost does what I want but it only pulls records that are exactly 45 days old. I need 45 and older.
Any help is greatly appreciated.
-RHJ