The index was helped by a 4% gain for shares in Microsoft, which rose following a report that the company has narrowed its search for a new chief executive.
Overall the Dow Jones Industrial Average closed 128 points or 0.8% higher at 15,746.
The S&P 500 closed 0.4% higher at 1,770 – just one point short of its record.
“The markets are going to slowly drift up higher, unless there is something to keep it from happening,” said Randy Frederick, from stock broker Charles Schwab.
Traders are also betting that the US Federal Reserve (the Fed) is unlikely to end its stimulus programme in the near future.
Currently it is pumping $85bn into the economy every month by buying government bonds, which is helping to keep interest rates extremely low.
Late on Tuesday the president of the San Francisco Federal Reserve Bank said the Fed should wait for more solid evidence of economic growth before phasing out that effort.
“What’s seeping into the market is the increasing likelihood [the Fed] will keep zero percent interest rates for 18 months longer than they had signalled previously,” said Steven Einhorn from the hedge fund Omega Advisors.
Meanwhile Microsoft shares jumped more than 4% following a Reuters report that the company has narrowed the list of potential new chief executives to five people.
It says the list includes Ford chief executive, Alan Mulally and former Nokia chief executive, Stephen Elop.
Microsoft has been looking for a new boss since August when Steve Ballmer said he would step down within a year.
Investors are hoping for a shift in strategy at Microsoft, which is still very profitable, but has been overtaken in important areas of technology by rivals including Google and Apple.