Date 在条令中查询日期

Date 在条令中查询日期,date,symfony,doctrine-orm,doctrine,symfony-2.1,Date,Symfony,Doctrine Orm,Doctrine,Symfony 2.1,我有一个名为active\u plans的表,其中有两列:activated\u date和last\u billed\u at。基本上,我想创建一个查询,查看以下两列: select all from active_plans where last_billed_at = null AND activated_date + 1 month = today, or if last_billed_at + 1 month = today. 不过,我似乎

我有一个名为
active\u plans
的表,其中有两列:
activated\u date
last\u billed\u at
。基本上,我想创建一个查询,查看以下两列:

select all from active_plans 
          where last_billed_at = null AND activated_date + 1 month = today, 
          or if last_billed_at + 1 month = today.

不过,我似乎不知道该怎么做。

我最后做了一些非常不同的事情: 公共函数getBillToday() { $activePlans=$this->entityManager ->createQuery('从adp中选择adp 其中adp.activationDate不为空') ->getResult(); $data=array()


如果有帮助,两列都是日期时间格式。
从活动设备计划中选择*,其中(上次计费日期=NULL和日期(激活日期)=日期(日期子(现在(),间隔-1个月))或(日期(上次计费日期)=日期(日期子(现在(),间隔-1个月)))
不起作用,使用Doctrine的createNativeQuery…我不知道还有什么其他方法可以做到这一点。
    foreach ($activePlans as $plan) {
        $recur = $plan->getPlan()->getRecurringInMonths();
        $nextBillTime = strtotime('-'.$recur.' months', time());
        $nextBill = date('Y-m-d', $nextBillTime);
        $activationDate = $plan->getActivationDate();
        $lastBilledAt = $plan->getLastBilledAt() != NULL ? $plan->getLastBilledAt()->format('Y-m-d') : 0;
        if ($activationDate == $nextBill || $lastBilledAt == $nextBill) {
            $data[] = $plan->getId();
        }
    }

    return $data;
}