Here’s the good news for department stores: business isn’t getting worse.

Macy’s Inc. and Kohl’s Corp. reported second-quarter financial results Thursday that showed a slower decline in same-store sales from the beginning of the year, which followed a disappointing holiday season.

Macy’s same-store sales — a metric that tracks sales at established locations that haven’t recently opened or closed — fell 2.8%, better than the 5.2% retreat in the first quarter. Analysts on FactSet had predicted a 3.3% decline.

Kohl’s same-store sales retreated 0.4% in its latest quarter, less than the 2.7% decline in the first quarter and the 1.5% expected by analysts.

Still, foot traffic has steadily slowed at brick-and-mortar stores as shoppers increasingly turn to Amazon.com Inc. and e-commerce to spend their dollars. Both Macy’s and Kohl’s have seen same-store sales shrink for several quarters in a row.

Shares of Macy’s rose nearly 1% in premarket trading to $23.25, while Kohl’s slipped 2.2% to $40.99. Shares of Dillard’s Inc., which Thursday surprised analysts by swinging to a loss, tumbled 13.2% in premarket trade to $63.65.

The shift to online shopping has pinched Macy’s and its peers, which have responded by closing weaker locations and…