"What if I didn’t live in the home for two years?"
If you don’t live in the house for two years, you might not be eligible for any of the exclusion. Let’s say that you bought a condo on Beacon Hill for $400,000 and one and one half years later you decided to sell it for $600,000 and move to Cambridge. Your gain of $200,000 is taxable.
If the sale is due to a job related move, or other unforeseen circumstances (the IRS web site can give you some nice specifics on this one), you are eligible for an exclusion up to a prorated amount. Let’s say that instead of moving to Cambridge, you relocate to take a new job Los Angeles. As you lived in the old residence for one and one half years out of two, you can exclude up to one three quarters (75%) of the maximum amount. For a married couple this would mean up to $375,000 (75% of $500,000) and $187,500 for a single person.