Fix date range calculation