After weeks of hovering around its July 26 record, the S&P 500 came within inches of reaching its all-time high on Friday.