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?
This is what I have currently:
$query = $this->query("SELECT u.id, u.name, u.email, u.registered, g.name as group_name FROM `:@users` AS u LEFT JOIN `:@groups` AS g on u.group_id = g.id WHERE u.last_login = ...... LIMIT {$limit_start}, {$limit_end}");
:@ = database prefix
Try using
date_sub(Similar to the first answer but in my mind it is more "natural" to use positive integers)