Create variables using aggregate()

Create maxdate and mindate using aggregate function.