After knocking on the door all week, the stock market logged a record Thursday.

Stock watch

Year to date:

The Dow is down 304.01, or 1.8%

The S&P 500 is up 5.93, or 0.3%

The Nasdaq is up 142.34, or 3.4%

Source: AP

The broad-based S&P 500 index had moved above its previous all-time high on numerous occasions this week, only to fade in afternoon trading. On Thursday, the index stayed higher after getting a boost from strong earnings reported by a number of U.S. companies including the drugmaker Mylan and several retailers.

The stock market has staged an impressive turnaround in February, after slumping at the start of the year on concerns about the prospects for growth in China and worries about the health of the U.S. economy. Growth in corporate earnings and optimism that the Federal Reserve will keep supporting the economy have helped support demand for stocks.

"In the last few days we've flirted with it, and now we've got the new high," said Ryan Detrick, a senior technical strategist at Schaeffer's Investment Research.

The timing of the new record, just before the start of spring, could help the market extend its gains, Detrick said. March has been the third-strongest month over the last 30 years, with an average gain of 1.4 percent, according to the Stock Traders' Almanac.

"It bodes well for equities for the next couple of months, at least," said Detrick.

The S&P 500 rose 9.13 to 1,854.29. Its previous record high close was 1,848.38, set Jan. 15.

The Dow Jones industrial average climbed 74.24 to 16,272.65. The blue-chip index is about 1.8 percent below its record close of 16,576.66.

The Nasdaq composite gained 26.87 to 4,318.93. It's also short of its record close of 5,048.62 set in March 2000.

Generic drugmaker Mylan led the S&P 500 higher Thursday after reporting an 11 percent increase in fourth-quarter earnings, beating expectations. Stocks also got a lift from a range of retailers, including J.C. Penney, Kohl's and Sears Holdings.

After a tough start to the year, investor sentiment has shifted in February. The S&P 500 was down almost 6 percent for the year at the start of the month. It has erased those losses and is now positive for the year.

Some of the shift was thanks to the new Federal Reserve chief, Janet Yellen.

Stocks jumped on Feb. 11, when Yellen said she would continue the central bank's market-friendly, low-interest rate policies. The comments were her first since taking over from Ben Bernanke earlier this month.

On Thursday, she told the Senate Banking Committee that some recent economic data have suggested sluggish growth in consumer spending and employment. Yellen said the Fed will be watching to see if the slowdown proves to be a temporary blip caused by the severe winter weather. Her testimony Thursday didn't have the same impact on the stock market as it did earlier.

The current environment of moderately improving growth and low interest rates still make it an attractive environment for investing in stocks, said Dan Curtin of JPMorgan Private Bank.

"The data points that we are seeing, although slightly weaker than we might have thought, are still positive for equity valuations," said Curtin.