There are three tests you must meet in order to exclude the gain from the sale of your main home: 1  Ownership: You must have owned the home you are selling for at least two years during the five years prior to the sale.