Hi,
I've got a table of members. I want to be able to produce a list of:
a) Members who have been added/modified in the last 30 days
b) Members who are about to expire in the next 30 days (I mean their membership, not their lives!)
I know it's got something to do with Curdate() and INTERVAL 30 days, but I can't seem to make it work.
Here's my code:
$result = $connector->query('SELECT id, firstname, surname, memnum, email, UNIX_TIMESTAMP(expdate) AS expdate FROM members WHERE expdate >= DATE_ADD(CURDATE(), INTERVAL 30 DAY) ORDER BY joindate DESC')or die ("Error in Query: $query.".mysql_error());
I'm assuming the > operator means dates from now and < means before now, but I keep getting incorrect results. I've got 2 entries in the test db, one with an expiry at the beginning of the month, one with an expiry at the end of the month. I either get both showing or neither.
Could someone point me in the right direction please? I couldn't get much sense out of the SQL manual!