Pawel Wasilewski

SugarQuery with dateBetween in 7.7

Discussion created by Pawel Wasilewski on Nov 2, 2016
Latest reply on Nov 2, 2016 by Pawel Wasilewski

Hey,

i try to build sql query with where clauses.

$SugarQuery
    ->where()
//        ->queryOr()
            ->dateBetween('field01',array($start,$stop))
            ->dateBetween('field02',array($start,$stop))
;

How to add OR between dateBetween?

I try to achieve

WHERE 
  simple_module.deleted = 0
AND (
  (simple_module.field01 >= '2016-11-02' AND simple_module.field01 <= '2016-11-02')
  OR (simple_module.field02 >= '2016-11-02' AND simple_module.field02 <= '2016-11-02')
)

When you uncomment queryOr() all ANDs inside "dateBeteween will be ORs.

 

 

Outcomes