changed query for custom dates