select the date range properly