BetaCodeShareBeta

by Code Solutions Project

Simple solutions for common problems

Description:Get all birthdays of users in a date
SQL
JoseluCross
SELECT * FROM Users WHERE DATE_FORMAT(fecha_nac,'%m-%d') = DATE_FORMAT('date', '%m-%d')

Input example

'2018-08-31'

Output example

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

Other implementations

PHP
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();
}
×Oh snap! Something wrong