Update entity with query criteria : Incorrect date value

  criteria, doctrine-orm, dql, symfony

I wrote doctrine query builder for updating entity where field endDate is null.

public function update(int $clientId, DateTime $endDate): void
    $qb = $this->createQueryBuilder('s');

    $qb ->update(User::class, 's')
        ->set('s.endDate', $endDate->format("Y-m-d"))
        ->where('s.clientId =:clientId')
            $qb->expr()->gt('s.endDate', $endDate->format("Y-m-d"))
        ->setParameter('clientId', $clientId)

I don’t know where and why this error is coming from:

Invalid datetime format: 1292 Incorrect date value: ‘1995’ for column ‘end_date’ at row 1"

I tried basically every ->format example. It work’s on other methods..

Source: Symfony Questions