Better date handling in the agg function and better date display format