Fix date range in query