I’m trying to use the templated filtering to achieve something like:
IF((hold_date BETWEEN ‘2017-03-29 00:00:00’ AND ‘2017-03-29 23:59:59’) AND (t_stamp NOT BETWEEN ‘2017-03-29 00:00:00’ AND ‘2017-03-29 23:59:59’), 1, 0) AS outside
The templated filter I have used is:
IF(({% condition orders.t_stamp_date %} o.hold_date {% endcondition %}) AND (NOT {% condition orders.t_stamp_date %} o.t_stamp {% endcondition %}), 1, 0) AS outside
and it generates the following sql:
IF((((( o.hold_date ) >= ((DATE(NOW()))) AND ( o.hold_date ) < ((DATE_ADD(DATE(NOW()),INTERVAL 1 day)))))) AND (NOT ((( uo.t_stamp ) >= ((DATE(NOW()))) AND ( uo.t_stamp ) < ((DATE_ADD(DATE(NOW()),INTERVAL 1 day)))))), 1, 0) AS outside
The issue here is that the sql after NOT doesn’t work as expected and thus makes the overall IF block return 0 everytime.
Any suggestions how to implement this correctly?