Stocks Log 3-Day Gain, Dow at 3-1/2 Year High

Stocks squeezed out a small gain for the third-straight session Thursday, but the day's gains were limited as enthusiasm over reports over a Greek deal faded and investors were unmoved following some better-than-expected economic news.

The Dow Jones Industrial Average eked out a gain of 6.51 points, or 0.05 percent, to finish at 12,890.46, closing at its best level since May 2008. Earlier in the session, the blue-chip index set a new multi-year intraday high of 12,924.71.

United Tech and AmEx led the blue-chip gainers, while Cisco lagged.

The S&P 500 added 1.99 points, or 0.15 percent, to end at 1,351.95. The Nasdaq added 11.37 points, or 0.39 percent, to close at 2,927.23.

The CBOE Volatility Index, widely considered the best gauge of fear in the market, closed above 18.

Among the key S&P sectors, techs gained, while health care lagged.

“We seem to be overbought in the near-term, but we’re encouraged by the fact that the economic news in the U.S. continues to improve and we’re not as handicapped to what’s going on in Europe as we were in the past,” said Ryan Detrick, senior technical strategist at Schaeffer’s Investment Research. “We’ve been seeing a sideways market instead of a big pullback, so the market is catching its breath.”

Greece announced an agreement to cut costsand keep from defaulting on its debt next month, according to reports.

Meanwhile, stocks traded sideways as many traders and skeptics warned that the market had already expected the deal and said Europe still faces problems. (Read More: Markets Finally Get Greek Deal —So Where's the Big Rally?)

“Investors are not that hopeful that the details of the deal will be as compelling as they hoped,” said Steve Neimeth, portfolio manager at SunAmerica Asset Management. “Net-net, today’s news can be viewed as a situation where the ECB is kicking the can down the road…it also appears that investors are now asking if other countries such as Portugal and Ireland will request the same relief.”

Still, the euro hit a two-month highagainst the dollar and European stocks closed higherfollowing the reports.

Earlier, the ECB kept interest rates on hold at 1 percent, as expected. However, ECB President Mario Draghi hinted at relaxed rules for banks taking part in a long-term refinancing operation at the end of the month, boosting hopes that additional liquidity will be injected in the system.

Apple gained to hit another all-time highamid speculation about an announcement about an iPad 3 in March and after Canaccord Genuity raised its price target to $665 from $650.

Among earnings, Pepsico fell after the beverage giant reported better-than-expected profit, but forecast a 5 percent decline in 2012 earningsas it increases advertising and marketing costs. In addition, the firm said it plans to cut 8,700 jobs in a restructuring.

Cisco led the Dow laggards even after the tech bellwether posted better-than-expected results and announced plans to raise its dividend. Meanwhile, at least six brokerages raised their price targets on the firm.

Credit Suisse also slumped after the bank posted a surprising quarterly loss.

And Groupon plunged sharply a day after the online deal company posted an unexpected lossin its first quarterly results since going public.

Meanwhile, Visa rallied after the credit-card provider topped earnings estimates and authorized a new $500 million share repurchase program. In addition, at least eight brokerages boosted their target prices in the company.

And Akamai surged after the Internet content delivery company reported earnings that topped expectations and forecast first-quarter revenue above estimates.

Activision Blizzard and LinkedIn are among companies slated to post earnings after-the-bell tonight.

Diamond Foods plunged following news of an internal investigation that found the company had improperly accounted for paymentsto walnut growers. The company’s CEO and CFO have been placed on leave and the news puts the company’s potential purchase of the Pringles brand from P&G in doubt.

On the economic front, weekly jobless claims declined 15,000 to a seasonally-adjusted 358,000, according to the Labor Department, hitting the second-lowest level in almost four years.

And wholesale inventories rose 1.0 percent in December, according to the Commerce Department.

Treasury prices held their lossesafter the government auctioned $16 billion in 30-year notes at a high yield of 3.240 percent and a bid-to-cover of 2.47.

—Follow JeeYeon Park on Twitter: @JeeYeonParkCNBC

Coming Up This Week:

FRIDAY: International trade, consumer sentiment; Earnings from Barclays

More From CNBC.com: