In 1885, the regiment was transferred to the Department of Arizona. Once again the 10th was involved in the arduous pursuit of Apaches who left the reservations under the leadership of Geronimo, Nana, Nachez, Chihuahua and Magnus. The 10th Cavalry continued to fight Apaches after Geronimo's surrender in 1886. A detachment of 10th Cavalry would fight one of their last battles of the Apache Wars north of Globe at the Salt River during an expedition on 7 March 1890. After the battle Sergeant William McBryar, was awarded the Medal of Honor for his actions during the pursuit of the Apache warriors. After twenty years of service on posts in the southwest, the regiment, now under the command of Colonel John K. Mizner, was transferred to the Department of Dakota in 1891 The regiment served at various posts in Montana and Dakotas until 1898. During this time, a young white lieutenant, J. Pershing  commanded a troop from Fort Assinniboine in north central Montana. Pershing commanded an expedition to the south and southwest that rounded up and deported a large number of Cree Indians to Canada. In summary, from 1866 to the early 1890s, the 10th Cavalry Regiment served at a variety of posts in the Southwestern United States  and Great Plains regions. They participated in most of the military campaigns in these areas and earned a distinguished record. Thirteen enlisted men and six officers from the Buffalo Soldiers  earned the Medal of Honor during the Indian Wars.
Question: For how many years did the 10th regiment serve at various posts in Montana and the Dakotas?
Answer: 7