best advice ever: in order to allow an index on the column to be used, and therefore to make your query perform well, it is important never to apply a function to a column
so your DATEDIFF approach is dead right out of the starting gate
a wise man once said that it is far better to get the correct answer after a while than a wrong answer immediately…
and to be sure, DATEDIFF can give you the right answer, but it’s not efficient
if you’re trying to find “more than 3 days old” you should do it this way –
WHERE `timestamp` < CURRENT_DATE - INTERVAL 3 DAY
note that you shouldn’t use a reserverd word like TIMESTAMP for the name of a column
You are correct… and thanks for the link! I read through the page, and have tried the following:
SELECT *
FROM homepage_homeschool_schedule
WHERE dbTime < (SELECT CURRENT_TIME - INTERVAL 3 DAY)
I changed TIMESTAMP to read dbTime because I thought that maybe using TIMESTAMP as a variable name wouldn’t be a good idea. Regardless, now I have no error, but whether by inequality is less than or greater than, I get no rows back.
My goal is to get all records with dbTimes that are earlier than 3 days in the past. Any additional thoughts or hints would be appreciated.
Thank you for the solution and your patient response: due to a lag in receiving your messages, it only seemed as though I wasn’t taking your advice right off the bat.