In table column (a.paymentDate) date is inserted in Y-m-d H:m:i format. I want to query all the entries in particular date. For that I have to change the date format from Y-m-d H:m:i to Y-m-d. My query is given bellow.
namespace Regal\SmsBundle\Repository;
use Doctrine\ORM\EntityRepository;
/**
* DailyTransactionRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class DailyTransactionRepository extends EntityRepository
{
public function getDailyPayment($studentId,$paymentDate)
{
$paymentDate= new \DateTime('2013-03-11');
$query = $this->getEntityManager()->createQuery("
SELECT a.id, a.amont, a.paymentDescrip, a.paymentType, a.paymentDate
FROM RegalSmsBundle:DailyTransaction a
WHERE DATE(a.paymentDate) = :paymentDate AND a.students = :studentId
")
->setParameter('studentId', $studentId)
->setParameter('paymentDate', $paymentDate->format('Y-m-d'))
;
return $query->getResult();
}
}