Investors & landlords

You need to have lived in the home as your personal primary residence for a total of 730 days during the 5 year period from the date of purchase to avoid capital gains.

See IRS Publication 523 Selling Your Home page 3 - https://www.irs.gov/pub/irs-pdf/p523.pdf#page=3