Can you try if below code chunk works?
WHERE sets.importDate >= :beginDate AND (sets.importDate <= :endDate OR :endDate IS NULL)