I am trying to run the following query:
SELECT COUNT(*) FROM (
SELECT * FROM vqm_packets WHERE call_end >= DATE_SUB(NOW(), INTERVAL 1 MINUTE)
UNION ALL
SELECT * FROM vqm_archive WHERE call_end >= DATE_SUB(NOW(), INTERVAL 1 MINUTE)) AS t;
I am trying to find only records newer than 1 minute. One would think that further restricting the interval (changing to 1 second for example) would decrease the record count, but it is not. I would assume that the issue is with my time restriction based on the call_end field (a datetime field, in UTC). Just curious if anyone can see any issues with the query? If not, are there any issues when using now() and UTC?
If your datetime fields are set to UTC times, then you would want to use UTC_TIMESTAMP() instead of NOW() for comparisons.