I am trying to get the all records which are 2 hours or more old using this query:
$minutes = 60 * 2
SELECT COUNT(id) AS TOTAL, job_id
from tlb_stats
WHERE log_time >= DATE_SUB(CURRENT_DATE, INTERVAL $minutes MINUTE)
GROUP BY job_id
It only selects the recent records and skips the old. When I change log_time <= ...
it only selects old and skips which are the new one.
What am I doing wrong?
<=
) to the current time minus 2 minutes, (i.e. now: 22:06, 2 mins ago is 22:04, so you want a record with 22:03, which is less then 22:04). – Multiplicity