Given that you have a DATETIME field in your database, it is likely that using LIKE (it depends entirely on the database and table mechanism) you are not using algorithms optimized for DATE operations.
One solution is to specify the whole day (from the first to the last second) using the BETWEEN operator, which is supported by DQL , as shown in it EBNF:
$em->createQuery("SELECT sz FROM Szerzodes sz WHERE sz.exportalva BETWEEN '2012-05-17 00:00:00' AND '2012-05-17 23:59:59'")
If you really want to use the function for this, it is also useful to use the function always in the value, and not in the column used in this state. Some databases (e.g. MySQL) do not use indexes on columns modified with built-in functions. You can create a user-defined function called DATE that does what you expect (this can easily complete the previous example above) using the DQL User-defined function .
Augusto pascutti
source share