New York (CNN Business) The Dow recorded its best month of the year in June. It climbed 7.19%, narrowly beating its 7.17% gain in January.

The S&P 500 and the Nasdaq Composite, meanwhile, logged their best months since January, rising 6.9% and 7.4%, respectively. On top of that, the S&P is up 17.4% for the year, marking its best first half since 1997.

The Dow hasn't done that well in the month of June since 1938, while the S&P recorded its best June since 1955.

In short, it was quite the month for stocks.

Stocks rose in June on hopes that the Federal Reserve will soon cut interest rates to boost the economy. The strong rally has outweighed a few bad days caused by geopolitical and trade worries.