By default Doctrine does not support all the functions of a specific vendor, such as the DATE_ADD
. However, you can use custom defined functions. That link has an example specifically for date add.
Extending DQL in Doctrine 2: User-Defined Functions
The other option, depending on the complexity of the query, is just to handle this in the application code. if your mydatetimefield
is actually a datetime, Doctrine will convert that to a php DateTime
in the returned object.
$myDateTimeField = $object->getMyDateTimeField();
$myDateTimeField->add(new DateInterval( $object->getMyField1() + $object->getMyField2() . 'M'));
Lastly, you could always use dbal
as well.