How can I extract part of the date (eg the month) in DQL?
I'm trying to use a query something like this:
$query = $qb->select('u')
->from('user', 'u')
->where('MONTH(u.birthdate)', $month)
->getQuery();
I'm trying to select all users who's birthday is in the current month. Is this possible? how?
尝试
->where('MONTH(u.birthdate)=:month')->setParameter("month", $month)
To enable those MySQL function like MONTH, YEAR, etc, you will have to first install them and enable them, you can get it here from Benjamin Eberlei Doctrine 2 Extensions
and follow the instrucions.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.