In order to qualify for the exclusion of gain on the sale of your home, you have to meet what are called the ownership and use tests. These basically mean that you must have owned and lived in the home as your main home for at least 2 years during the 5-year period prior to the date of sale. Also, you cannot have excluded gain on the sale of another home within the 2-year period prior to the date of sale of your current home. In other words, you cannot claim an exclusion twice within the same 2-year period.
If you owned the home jointly with another person, each of you can claim an exclusion of up to $250,000 of gain on the sale, provided you meet the tests. If you are married and file jointly, you can claim an exclusion of up to $500,000, provided that either or both spouses meet the ownership test, both spouses meet the use test, and neither of you has excluded gain on the sale of another home in the 2 years before this sale. If you are married filing separately, each of you will have to figure your own portion of the gain or loss according to your ownership interest, as determined by state law. For example, in community property states, you would each normally own 50% of the home.
The 2 years of ownership and use during the 5-year period do not have to be continuous, and the periods of ownership and use do not necessarily have to coincide. For example, while you own the home you may live somewhere else during part of the 5-year period. As long as you meet the total 2-year requirement for both ownership and use at some time during the 5-year period, you will qualify for the exclusion. Temporary absences from your home, during vacations for example, are considered periods of use, even if you rent out your home while you are absent.