I'm building a query so I can get a list of new users by month:
public function getNewUsers($month) {
$month = date('F', strtotime($month));
$sql = "SELECT * FROM `{$this->table}` WHERE MONTHNAME(`account_creation_date`) = {$month} ORDER BY `id` DESC";
$stmt = $this->pdo->prepare($sql);
$stmt->execute([$month]);
if ($stmt->rowCount() == 0) return null;
$users = $stmt->fetchAll(PDO::FETCH_NAMED);
foreach ($users as &$user) {
$user = $this->applyRelations($user);
}
return $users;
}
An example of "account_creation_date" value is "08/08/2019 4:55 pm"
Im trying to pass in a month name like "August" and have the query convert the account_creation_date values to their month names.
Although I'm getting no errors, nothing is returning when the query is executed.
How can I accomplish this? Is MONTHNAME what I want?
Thanks!