Mysql 5 5 Now Bug

consider the following query:

SELECT COUNT(DISTINCT(mac)) AS total FROM stats WHERE sighting_time BETWEEN DATE_SUB( NOW(), INTERVAL {period} SECOND) AND NOW();

If you are running mysql < 5.6.12, you are golden. In 5.5.22, will return 0.

solution:

CAST(NOW() AS char)
SELECT COUNT(DISTINCT(mac)) AS total FROM stats WHERE sighting_time BETWEEN DATE_SUB( CAST(NOW() AS char), INTERVAL {period} SECOND) AND CAST(NOW() AS char);