在表格列中以格式(a.paymentDate)
插入日期。Y-m-d H:m:i
我想查询特定日期的所有条目。为此,我必须将日期格式从 更改Y-m-d H:m:i
为Y-m-d
。我的查询如下。
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();
}
}