fix dates issues for aggregation query