Answer by taking a quote from the following article:

Affirmed (February 21, 1975 - January 12, 2001) was an American Thoroughbred racehorse who was the eleventh winner of the United States Triple Crown of Thoroughbred Racing. Affirmed was also known for his famous rivalry with Alydar, whom he met ten times, including in all three Triple Crown races. Affirmed was the last horse to win the Triple Crown for a 37-year period, which was ended in 2015 by American Pharoah. Affirmed won fourteen Grade

As a four-year-old in 1979, Affirmed started the season with a third place in the Malibu Stakes and a second in the San Fernando Stakes. He had a five race losing sequence prior to starting in the Charles H. Strub Stakes at Santa Anita Park. Laz Barrera replaced Cauthen with Pincay and Affirmed didn't lose again and would dominate the handicaps the rest of the year.  Affirmed won the Strub Stakes, and then ran in the Santa Anita Handicap against Exceller, who had defeated Seattle Slew in 1978. Affirmed won easily, running the  1 1/4 miles in 1:58 3/5, setting a stakes record in California's most important stakes race that stood until 2014. Affirmed then went to Hollywood Park, where he won the Californian Stakes, carrying 132 pounds, he then won the Hollywood Gold Cup in a three horse finish, from Sirlad and Text, setting an all time earnings record and running the 1 1/4  miles in a fast 1:58 2/5. Affirmed picked up the Woodward Stakes at Belmont Park, and then faced one more all-time great horse, three-year-old Spectacular Bid, in the Jockey Club Gold Cup, also at Belmont. Spectacular Bid, like Alydar, preferred to run off the pace, and once again, Affirmed was allowed to set a slow pace, going the first half mile in 49 seconds. Spectacular Bid issued challenges at Affirmed, but Affirmed won. Spectacular Bid was undefeated during the rest of his racing career.  Affirmed was named Horse of the Year and the American Champion Older Male Horse of 1979, having won 7 of 9 starts with 1 second and 1 third as a four-year-old and earning $1,148,800. In his career, Affirmed earned a then record $2,393,818 (the first Thoroughbred in North America to win over $2 million) with 22 wins, 5 seconds and 1 third from 29 starts.  His trainer, Laz Barrera, once said: "Affirmed is greater than Secretariat, or any Triple Crown winner, because only Affirmed had to face Alydar."

How long did they work together?