This article originally appeared Boomer Magazine on November 1, 2019

Perhaps you are moving closer to family, downsizing, or maybe you just found a better vacation home in the Hamptons.

In any case, it can be a bittersweet moment, but it doesn’t have to be painful at tax time.

It just requires a little planning and some tax knowledge mixed in for good measure.

The IRS allows you to exclude up to $250,000 of gain from the sale of your principal residence and up to $500,000 if you are married and filing a joint return. How do you determine how much gain you will have? It is simply the difference between the sale price of the home and what you paid for it. What you paid for the home also includes what you spent to improve it and a possibly few other normal closing costs. Losses are not deductible on a personal residence but a gain can be excluded from taxation if it meets three tests.

The first test is simply whether or not you owned the home, i.e. who is legally listed as the owner. You must have owned the residence for a total of two years that fall within the five-year period preceding the date of the sale.

For this test it does not matter if you owned for all five years or just years one and two.

In addition to ownership you must have also occupied the residence, as a principal residence, for at least two years during the same five-year period for the ownership test.

It can get a bit more complicated if you owned multiple residences during this time, but a good rule of thumb is to use the residence where you spend the most time.

The final test is that you must not have used the gain exclusion for any other residence sold or exchanged during the two-year period preceding the date of the current sale. If you have not sold a different home in the last two years, then you will likely meet this test.

One interesting point is that the ownership and use test do not have to be concurrent. For example, if over a five-year period, you rented a home in years one and two then bought and owned that same home in years three and four and then sold the home in year five, you will have met the first two tests even if you did not actually reside in the home in years three and four. As long as you have not used the exclusion of gain from sale of a main home in the last two years, then you can check the box for all three tests.

Every situation is unique and might include complicating factors such as adjoining land, property inherited from a relative or spouse, or unforeseen circumstances that made it necessary to sell your home before the previously mentioned tests were met. Make sure to consult your advisor so they can help you plan for your next big move.

Roy Ice, CPA

Roy Ice, a native of Vincennes, is a graduate of the University of Southern Indiana, where he earned a Bachelor of Science in accounting in 2012. He became a licensed CPA in 2014 and is a partner with Kemper CPA Group. He lives in Vincennes with his wife, Katelyn, and their son, Lockhart.