BetaCodeShareBeta

by Code Solutions Project

Simple solutions for common problems

External library: doctrine/dbal Version used: 2.5
Description:Get all birthdays of users in a date
PHP
MagRag
public function getBirthdays(){
    $queryBuilder = $em->createQueryBuilder();
    $queryBuilder
        ->select("*")
        ->from("Users")
        ->where("DATE_FORMAT(fecha_nac,'%m-%d') = DATE_FORMAT(NOW(), '%m-%d')");
    return $queryBuilder->execute()->fetchAll();
}

Input example

'2018-08-31'

Output example

All users whose fecha_nac (month and day) are the same of 'date' content

Other implementations

SQL
SELECT * FROM Users WHERE DATE_FORMAT(fecha_nac,'%m-%d') = DATE_FORMAT('date', '%m-%d')
×Oh snap! Something wrong