In the 19th century army, it seems that regimental commanding officers were allowed to retain command as long as they continued breathing. This
resulted in a large backup of older officers in lesser ranks.
Consider Major Robert Anderson at Fort Sumter, West Point Class of 1825, born in 1805, 56 years old at Ft. Sumter with 36 years commissioned service behind him.