I have fields in my table for date, but they contain everything - day, year and month. Can I write a query to get only the records, which has month equal to the current month? I can do this:
$today = new \DateTime(); $month = $today->format('m'); $cat = $em->getRepository('EMBudgetTrackerBundle:Expense')->find(1); $ex_date = $cat->getDate(); and compare $month and $ex_date, but can I write some kind of query? Something like this:
public function getExpensesByMonth($month) { $q = $this->createQueryBuilder('e'); $q->select('e') ->where('e.date = :date') ->setParameter('date', $month); return $q->getQuery()->getResult(); } Thank you in advance! :)