Function for calculating max/min years in forms