It is anyone's guess where stocks will be in a few months. But if you measure your investing horizon in years, then you have a much better chance at building wealth in the stock market.

With that long time frame in mind, let's look at a few attractive businesses that are likely to be posting much higher sales and earnings in five years.

Both Chewy (CHWY 0.25%) and Zoom (ZM 1.25%) are also conveniently trading at a big discount to the prices that investors were paying just a few months ago. Read on for some good reasons to consider putting $5,000 to work in these beaten-down stocks today.

1. Chewy

Chewy is a leading retailer of pet supplies that has used the e-commerce platform to make it easier for millions of pet owners to care for their furry companions. The company booked nearly $9 billion in global sales in 2021, compared to just $4.8 billion two years earlier .

Sure, investors can't expect that level of phenomenal growth to continue. Chewy is already seeing a growth hangover in 2022 as pet adoption rates settle back down to normal. Most Wall Street pros are expecting sales to grow just 12% this year.

Chewy's engagement metrics imply much more room for expansion over the next several years. Nearly 80% of its sales come from customers who choose auto-shipments, implying a level of commitment to the brand that most retailers can't claim. Chewy has also demonstrated pricing power as inflation spiked, which suggests steady earnings even through a further consumer spending slowdown.

The pet supply niche tends to hold up well during recessions, making Chewy an attractive option in today's bear market. But the better reason to like the stock is its bright long-term prospects as pet supply spending grows with each passing year.

2. Zoom

Few businesses were as dramatically boosted by the pandemic as Zoom. The video communication giant became indispensable to many homes and businesses during the lockdown phases and remained popular in the subsequent spike in hybrid and remote work.

Yet the stock is trading at near its pre-pandemic price despite the fact that it has a far larger sales footprint today. Many on Wall Street are worried that Zoom's best days are behind it.

That's an overreaction. Sure, its consumer-based product might struggle to grow in a post-pandemic world where people are increasingly moving back to in-person meetings and events. But Zoom continues to expand its list of enterprise clients. That segment should be much larger in five years thanks to the continued shift toward flexible working environments.

Zoom is also busily expanding its platform, adding on an AI-powered chat interface and a popular phone service in recent years. It remains profitable, too, meaning management should have the flexibility to continue investing in the business even through any recession ahead.

The big picture

There's no guarantee that Zoom, Chewy, or any stock will rise, let alone deliver market-thumping returns. But investors can maximize their returns by focusing on high-quality businesses and by extending their time horizon beyond the short term that tends to be Wall Street's focus.

Look beyond the next year or two, and you've got your best shot at building real wealth in the stock market.