I’m trying to fetch all rows from a table with a UNIX timestamp in the past 30 days.
SELECT count(member_id), DATE(FROM_UNIXTIME(`join_date`)) as date
FROM members
WHERE join_date > (join_date-'2592000')
GROUP BY DATE(FROM_UNIXTIME(`join_date`))
ORDER BY join_date DESC
There’s more going on there, obviously, as it groups them by day and converts them to a mysql time, but the important thing is the where clause that’s not working.. The rest of it is good.
I’m not getting any errors, but the query isn’t cutting off as expected.

EDIT: Got it.
SELECT count(member_id), DATE(FROM_UNIXTIME(`join_date`)) as date
FROM exp_members
WHERE DATEDIFF(CURDATE(), FROM_UNIXTIME(join_date)) < 30
GROUP BY DATE(FROM_UNIXTIME(`join_date`))
ORDER BY join_date DESC
This:
WHERE join_date > (join_date-'2592000')is almost certainly your issue.You probably want to compare join_date to
CURDATE(rather than itself-x) usingDATEDIFFthat way you can use whole day increments instead of seconds as 259200 which is better most human-readable-wise.