How to prepare queries based on date range in SCSP