Laravel $q->where() between dates

前端 未结 4 1065
死守一世寂寞
死守一世寂寞 2020-11-30 02:49

I am trying to get my cron to only get Projects that are due to recur/renew in the next 7 days to send out reminder emails. I\'ve just found out my logic doesn\

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 03:45

    @Tom : Instead of using 'now' or 'addWeek' if we provide date in following format, it does not give correct records

    $projects = Project::whereBetween('recur_at', array(new DateTime('2015-10-16'), new DateTime('2015-10-23')))
    ->where('status', '<', 5)
    ->where('recur_cancelled', '=', 0)
    ->get();
    

    it gives records having date form 2015-10-16 to less than 2015-10-23. If value of recur_at is 2015-10-23 00:00:00 then only it shows that record else if it is 2015-10-23 12:00:45 then it is not shown.

提交回复
热议问题