I have resolve the problem using doctrine extension [see]: https://github.com/uvd/Doctrine/tree/master/UVd/DoctrineFunction "UVD Doctrine"
config.yml
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
dql:
datetime_functions:
DATE_FORMAT: AppBundle\Extension\Doctrine\DateFormat
Usage
register function
protected function registerDateFunctions()
{
$emConfig = $this->getEntityManager()->getConfiguration();
$emConfig->addCustomStringFunction('DATE_FORMAT','AppBundle\Extensions\Doctrine\DateFormat');
}
create Query Builder
public function getAllRecords()
{
$this->registerDateFunctions();
$qb = $this->createQueryBuilder('r')
->select('r')
->addSelect('d')
->addSelect('b.country')
->leftJoin('r.religion', 're')
->leftJoin('r.country_of_birth', 'b')
->leftJoin('r.country_of_death', 'd')
->where('r.status = :status')
->setParameter(':status', 1)
->andWhere("DATE_FORMAT(r.dateOfDeath,'%m-%d') = :now")
->setParameter(':now',\date("m-d", time()))
->getQuery();
return $qb->getArrayResult();
}
credit: "http://www.uvd.co.uk/blog/using-mysqls-date_format-in-doctrine-2-0/"