You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '((NeverEnd = 'Y') or ((StartD <= '2017-10-18') and (StopD > '2017-10-18'))) orde' at line 1