I have 2 DateTime classes in Symfony2 project. I have entity Stat, in which have $date property.
/**
* @ORM\\Column(type=\"da
Benjamin's answer is correct, but it lacks one detail. This is the correct way to do it:
$qb->andWhere($qb->expr()->between('s.date', ':date_from', ':date_to'));
But to set parameters, I need to do like this:
$qb->setParameter('date_from', $date_from, \Doctrine\DBAL\Types\Type::DATETIME);
$qb->setParameter('date_to', $date_to, \Doctrine\DBAL\Types\Type::DATETIME);
If I omit the DATETIME types, I get the following error (see here):
Object of class DateTime could not be converted to string
I am using Doctrine DBAL 2.0.5, this behaviour might have changed in later versions of Doctrine.