I have a datetime column called \'last_login\'.
I want to query my database to select all records that haven\'t logged in within the last month. How do I do this?
You can use date_add combined with now:
...where u.last_login < date_add(now(), interval -1 month)
Naturally, as both are MySQL-specific this limits you to MySQL backends. Alternately, you can figure out what the date was a month ago with PHP (I'm not a PHP person, but I'm guessing DateTime::sub would help with that) and then include that date in your query in the normal way you would any other date/time field.