Fixed date creation and sorting in query. Correct updating of chart on re-query