Stocks pared gains and the Nasdaq turned negative on Thursday as Federal Reserve Chairman Ben Bernanke delivered congressional testimony for the second day and worries about hitting the U.S. debt ceiling dogged investors.

The Dow Jones industrial average <.DJI> gained 18.13 points, or 0.15 percent, to 12,509.74. The Standard & Poor's 500 Index <.SPX> gained 0.22 point, or 0.02 percent, to 1,317.94. The Nasdaq Composite Index <.IXIC> dropped 4.19 points, or 0.15 percent, to 2,792.73.

(Editing by Kenneth Barry)