I wrote a query in my Symfony that returns total sum of amounts per month of a year. But when I try to convert it from month number to month name it trows
Error: Expected Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS, got ","
My code..
$resultYearly = $this->getTransactionRepository()
->createQueryBuilder('p')
->select('MONTH(p.transactionDate, \'%b\') AS MonthOfYear, sum(p.amount) Total')
MonthAndYear, sum(p.amount) Total')
->where('p.transactionDate >= :end')
->setParameter('end', new \DateTime('-1 year'))
->groupBy( 'MonthOfYear')
->getQuery()
->getArrayResult();
It works perfect with DATE_FORMAT but when I use MONTH it throws an error..
Use
DATE_FORMAT(p.transactionDate,'%b') AS MonthOfYear