I tried this query below but it still returns days that had -1 values. I want the where clause to return rows that are 2 days or newer. Thanks!
SELECT uniqueKey,(TO_DAYS(TimeStampColumn) - TO_Days(Now())) as 'dayDiff'
FROM couponextractor.tblresults
where 'dayDiff' >= 0
Because you just compare string ‘daydiff’ >= 0, which always evaluates to 0 => true
You need to get rid of quotes and use HAVING, beside that’s very inefficient query… it’s better to compute the date before and just use >= operator on the column.
HAVING dayDiff >= 0
So just compute the exact date, and then just do
WHERE TimeStampColumn >= “XXXX-XX-XX AA:AA:AA” so it can be optimized by the server if you have indexes.