It's been over a decade since Apple (AAPL 0.52%) ran its "Get a Mac" campaign, a series of TV ads featuring a casually dressed man named Mac and a formally dressed man in a suit and tie representing a Microsoft (MSFT -2.45%) personal computer (PC). The ads ran from 2006 to 2009 and often depicted Apple computers as faster and hipper, while Microsoft's PCs were slow and outdated.

Now a piece of history in the tech world, the ad campaign was one of the last times Apple and Microsoft were truly put up against each other for all to see, as the businesses have slightly diverged. These days, Apple is more often compared to companies such as Samsung for its smartphones or even Netflix when discussing video streaming. Meanwhile, Microsoft is in a very heated console war with Sony

However, Microsoft has gone after Apple in recent years with its line of premium Surface laptops and tablets to more closely compete with MacBooks and iPads. As a result, tech investors might wonder which company's stock is the better buy. Let's find out.

Microsoft: A better short-term buy

Tech stocks have fallen out of favor in 2022, with the Nasdaq-100 Technology Sector index down 30% year to date as rising inflation and fears of a recession slow consumer spending. Microsoft has similarly been affected, losing a more moderate 20% in its stock price during the same period. The company is home to leading brands such as Xbox, Windows, and Office, and yet decreased demand in the PC market has sent its stock tumbling. Its recent dip might make it an excellent stock for investors with more short-term goals.

Microsoft's price-to-earnings ratio sits at 25% less than it was a year ago and considerably less than its average, suggesting its financials are in better standing than its stock price represents. Since July 2021, Microsoft's revenue has grown 18% to $198 billion, with free cash flow rising 16% to $65 billion. Meanwhile, its cloud computing service, Azure, claimed 24% of cloud infrastructure spending in the second quarter of 2022, an increase of 22% from the previous year.

As Microsoft's cloud business flourishes, its gaming endeavors are also ramping up. Its planned acquisition of games company Activision Blizzard will see Microsoft become the third-biggest game company by revenue after Tencent Holdings and Sony. The historic deal -- worth $68.7 billion -- is expected to close in the middle of 2023 after a review from regulators. Warren Buffett has made headlines on multiple occasions by buying up Activision stock ahead of the acquisition, most recently increasing Berkshire Hathaway's shares in August from 64.3 million to 68.4 million (worth $5.3 billion).

Apple: A great stock for patient investors

Microsoft offers much to like, but as one of the most consistently innovative companies in the world, Apple is the better stock for investors looking to buy and hold for the long haul. The iPhone company has proven its relative stability in 2022 with its stock down just 10% year to date -- half of Microsoft's decline.

The company doesn't have any known acquisitions or events as significant as Microsoft's purchase of Activision coming soon, but it has posted increasing revenue and net income for the past three years despite a global pandemic. In 2019, Apple's net sales totaled $260.2 billion; in 2020, it was $274.5 billion; and in 2021, it jumped to $365.8 billion. Net income also increased by 71.3% in the same period, reaching $94.7 billion.

Apple has continued to prove it's a stock worth hanging on to, reporting $83 billion in revenue in the fiscal third quarter of 2022 (ended June 25) -- a record for the company -- and up 2% from the previous year. Like clockwork, the company has forecast strong iPhone sales in 2023, with its current quarter likely receiving a boost from its new lineup of products announced on Sept. 7. The products include four new iPhones, which have received substantial price increases abroad, and a totally new Apple Watch Ultra that caters to a new market -- the outdoor adventurer. 

Microsoft and Apple are both promising companies with bright futures. Both would make good investments. As for which is the better buy, the answer depends on your investment strategy. Investors looking for a stock to buy on a 20% dip should set their sights on Microsoft. However, those in search of a stock to hold onto for years, with the chance for continued innovation, should look to Apple.