NEW YORK — After knocking on the door all week, the stock market logged a record on Thursday.
The Standard & Poor’s 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 points, or 0.5 percent, to 1,854.29. Its previous record high close was 1,848.38, set on Jan. 15.
The Dow Jones industrial average rose 74.24, or 0.5, percent, to 16,272.65. The Dow is still about 1.8 percent below its record close of 16,576.66. The Nasdaq composite climbed 26.87 points, or 0.6 percent, to 4,318.93. The Nasdaq is also short of its record close of 5,048.62 set in March 2000.
On Thursday, generic drugmaker Mylan led the S&P 500 index higher after reporting an 11 percent increase in fourth-quarter earnings, beating analysts’ expectations despite higher expenses. Mylan’s stock climbed $4.85, or 9.4 percent, to $56.27.
Stocks also got a lift from a range of retailers that reported strong earnings.
J.C. Penney jumped $1.51, or 25 percent, to $7.47 after the department store chain swung to a profit in the fourth quarter after posting a big loss in the same period a year earlier. Penney also reported its first quarterly gain in a key revenue figure in more than two years.
Kohl’s rose $1.30, 2.4 percent, to $55.74 after the department store operator reported earnings that topped analysts’ estimates. Revenue fell but met Wall Street’s expectations.
After a tough start to the year, investor sentiment has shifted in February.
The S&P 500 was down almost six percent for the year at the start of February. Investors were selling stocks as manufacturing contracted in China and as currencies in emerging market nations such as Turkey and Argentina plummeted against the dollar. The S&P 500 erased those losses this month and is now positive for the year.
Some of the shift in sentiment was also thanks to the new Federal Reserve chief, Janet Yellen.
Stocks jumped on Feb. 11, when Yellen told Congress 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, Yellen told the Senate Banking Committee that some recent economic data have suggested sluggish growth in consumer spending and employment. She said the Fed will be watching to see if the slowdown proves to be a temporary blip caused by the severe winter weather. This time, Yellen’s testimony 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, an investment specialist at 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.
In government bond trading, the yield on the 10-year Treasury note fell to 2.65 percent from 2.67 percent on Wednesday.
Among other stocks making big moves:
— Sears climbed $2.61, or 6.5 percent, to $43.01 after the company said its fourth-quarter loss narrowed. The operator of Sears and Kmart stores lowered expenses and reduced inventories. Sears has been trying to restore profitability by cutting costs, trimming inventory, selling off some assets and spinning off others.
— General Motors fell 6 cents, or 0.2 percent, to $36.77 after the U.S. government’s auto safety watchdog said it is investigating whether the automaker acted quickly enough to recall 1.6 million older-model small cars in a case linked to 13 deaths.