The S&P 500 (SNPINDEX: ^GSPC) is commonly viewed as a benchmark for the greater U.S. stock market. The broad-based index was introduced in March 1957, but its precursor was created in the late 1920s. Since then, it has returned an average of 0.7% in June, 1.7% in July, and 0.7% in August, according to data from research company Yardeni. In other words, history suggests the S&P 500 is headed higher over the next three months.

Of course, past performance is no guarantee of future results, and investors should shy away from short-term thinking. But even if those gains fail to materialize, the S&P 500 has produced a total return of about 10% annually over the long term. That means investors can assume the stock market might head higher in the future.

With that in mind, here's why Alphabet (GOOG 1.43%) (GOOGL 1.42%) and Paycom Software (PAYC 1.89%) are two stocks worth buying now.

1. Alphabet

Alphabet reported lackluster financial results for its first quarter of 2023. Revenue rose just 3% to $69.8 billion and earnings dropped 5% to $1.17 per diluted share. Those figures actually topped the consensus estimates on Wall Street, but top-line growth still decelerated significantly from 23% in the year-ago period, reflecting ongoing economic hardship. On the bright side, the bull case remains intact: Alphabet has a strong competitive position in adtech and cloud computing, two markets expected to grow by roughly 14% annually through the end of the decade.

Alphabet's success in digital advertising stems from its arsenal of popular web properties. Google Search, YouTube, and Chrome are the most popular search engine, streaming service, and web browser, respectively. Those web properties make Alphabet a valuable advertising partner for brands. The company is projected to account for 28.8% of global digital ad spend this year, and that figure is expected to reach 28.9% in 2024, according to eMarketer.

Alphabet is also gaining share in cloud computing. Google Cloud Platform (GCP) held a 10% market share in cloud infrastructure and platform services (CIPS) in the first quarter, up from 8% year over year. That momentum reflects an improved go-to-market strategy and continuous product development. In fact, research company Gartner says Google is improving its CIPS capabilities faster than any other cloud provider. That bodes well for the future.

Additionally, Google's expertise in artificial intelligence (AI) could be a significant growth driver in the coming years. The company may not have a viral app like ChatGPT, but industry experts have recognized Google as a leader in AI infrastructure, conversational AI platforms, and AI-powered document analytics. That puts the company in a good position. Ark Invest estimates the AI software market will grow by 42% annually through 2030.

Currently, shares trade for 5.8 times sales, a discount to the three-year average of 6.5 times sales. That creates an attractive buying opportunity for patient investors.

2. Paycom Software

Paycom provides an all-in-one human capital management (HCM) platform. Its core product is payroll software, but the company also offers tools for hiring, training, scheduling, and human resources management. Its broad portfolio is particularly noteworthy because most companies rely on multiple HCM vendors, but integrating disparate products makes life more complicated for administrators. Paycom removes that complexity, allowing clients to manage the entire employee life cycle (i.e., hiring through retirement) from a single platform.

Paycom has also distinguished itself through innovation. It debuted the industry's first self-service payroll software in 2021. The product, referred to as Beti (Better Employee Transaction Interface), automates payroll and reduces errors by requiring employees to review and approve their pay prior to processing. That makes life easier for administrators, who waste less time correcting payroll problems.

Paycom reported solid financial results for the first quarter despite operating in a challenging macroeconomic environment. Revenue jumped 28% to $452 million and GAAP net income rose 30% to $2.06 per diluted share. But management sees a long runway for future growth. Paycom has just 5% of its addressable market in the U.S., according to CEO Chad Richison, and the company plans to expand into international markets in the coming months.

In April, Paycom announced Global HCM, a product that will make its HCM software accessible in more than 180 countries. That means businesses with domestic and international employees can now standardize on the Paycom HCM platform, including its innovative payroll software Beti. Global HCM will significantly boost Paycom's total addressable market.

Currently, shares trade for 12 times sales, a discount to the three-year average of 20.8 time sales. That's why this growth stock is worth buying today.