Search code examples
symfonydatedatetimedoctrine-ormdql

How to comparison datetime with CURRENT_DATE() of DQL


$em = $this->getEntityManager();
    $query = $em->createQuery(
        "SELECT b
        FROM AppBundle:Booking b
        AND b.checkin IS NULL
        AND b.bookingDate=CURRENT_DATE()"
    );

I want to see the booking of today, but also i want to have the time of booking in bookindDate. So how to comparison datetime bookingDate with CURRENT_DATE() ?


Solution

  • $em = $this->getEntityManager();
    $query = $em->createQuery(
            "SELECT b
            FROM AppBundle:Booking b
            AND b.checkin IS NULL
            AND b.bookingDate >= CURRENT_DATE()
            AND b.bookingDate <= CURRENT_DATE()+1"
        );
    

    this work for me, too easy ;)