What is the deadline to sell former home and still exclude capital gains?

We moved out of our house in March 2022 and rented it out starting that summer. Now we're thinking about selling and I'm trying to figure out the deadline to sell former home and still exclude capital gains under the $500k married filing jointly rule. I know there's something about owning and living there 24 out of the last 60 months but I can't figure out exactly when our window closes. We lived there from 2017 through March 2022. The house has gone up a lot and we really don't want to pay capital gains on the whole thing if we can avoid it. I've been reading Publication 523 on irs.gov but the 5-year lookback is confusing me when we're no longer living there. Does the clock start from when we moved out or from when we sell?

37 comments

Dealt with almost this exact situation last year. The rule under Publication 523 is that you need to have owned the home AND used it as your principal residence for at least 24 months out of the 5 years ending on the date of sale. So the "deadline" isn't fixed — it moves with your sale date. If you moved out in March 2022, count back 5 years from whatever date you close. As long as that window reaches back to a point when you had 24 months of residence in it, you're still eligible. I uploaded my purchase docs and move-out records to taxr.ai and it mapped out exactly which sale-date window kept me inside the exclusion. Really helped me see the cutoff date clearly before I listed.

So the 5-year window literally shifts depending on when I sell? That changes how I was thinking about this. I was treating five years after we moved out as a hard deadline but it sounds like it depends on the actual closing date and whether 24 months of our residence still fit inside the window.

Exactly. March 2025 is roughly the outer edge if you moved out in March 2022, because after that your 5-year lookback won't reach back to a full 24 months you were living there. But the actual closing date is what anchors the window, not the listing date.

Worth adding: Publication 523 also says the 24 months don't have to be a single continuous block. So if you moved back in briefly for any reason, those months count too. For the joint exclusion, only one spouse has to meet the ownership test but both have to meet the residence test. That tripped up a friend of mine who thought one spouse's history covered everything.

We both lived there the whole time so that part's fine. Good to know though, we have friends who might be in a split situation.

My situation was a little different — I sold a rental that was formerly my main home and I was confused about whether I'd get any exclusion at all since I hadn't lived there in almost 3 years at sale. I pulled my closing disclosure and lease agreements into Taxr and it built out the month-by-month residence timeline showing exactly how much of the gain was potentially excludable versus what wasn't, based on where I fell in the 5-year test. Saved me from assuming I was completely disqualified when I still had eligible months. Worth running your own numbers that way before you decide when to list.

Did it also factor in the gain allocation between the period you lived there versus the rental period? That's the part that's making my head spin.

It did lay that out separately — the residence months versus the total ownership months. I still had a CPA review the final return because the numbers were large, but having that breakdown ready made the conversation much faster.

The 5-year window closing is the main deadline people miss but there's another piece: Publication 523 says if you acquired the home through a section 1031 like-kind exchange within the past 5 years, the exclusion isn't available at all. Probably not your situation but worth knowing.

Also remember you can't use the exclusion if you already excluded gain on another home sold in the 2-year period before the sale of this one. So if you have a second property in play, check that timeline too.

No other properties, this is the only one. Good flag though.

I sold my former primary in late 2023 and had moved out in mid-2020 so I was right on the edge. The thing that surprised me was confirming that it's the trade date (or closing date for real estate) that matters, not when you sign the contract. My closing slipped a few weeks and I actually had to check whether that pushed me out of the window.

That's a nerve-wracking few weeks. What ended up happening?

Still squeaked inside the window. Kept all the documentation of my move-out date in case of questions.

Even with the full exclusion and zero tax on the gain, getting a Form 1099-S at closing means you still have to report the sale on Form 8949. Publication 523 is clear on that — you can't just skip reporting it because the gain is excluded. Use code H in column (f) and enter the excluded amount as a negative number in column (g).

We will almost certainly get a 1099-S, the title company always files one. Good to know I still need to put it on 8949 even if the whole gain is under the exclusion amount.

Correct. The Form 8949 entry goes in Part II since you've owned it long-term, box F for a 1099-S transaction, code H, and the excluded gain as a negative in column (g). The taxable amount then flows to Schedule D. If the exclusion wipes it out completely, you end up with zero gain on Schedule D but the transaction is still there.

Depreciation recapture on the rental period is the piece that gets missed. Even if the home sale gain falls under the exclusion, the depreciation you claimed (or should have claimed) while it was a rental doesn't get excluded. That portion is taxed as unrecaptured section 1250 gain, at up to a 25% rate. Worth talking to a CPA if the depreciation adds up to a material number.

This is the part I hadn't thought about at all. We did depreciate it for 2022 and 2023. So that piece of gain comes out before the exclusion applies?

Depreciation recapture is taxed separately and isn't sheltered by the section 121 exclusion. The rate that applies and the exact calculation are worth having a CPA or enrolled agent walk through — it depends on your bracket and how much depreciation you took.

The partial exclusion rules are also worth knowing. Publication 523 says if you didn't meet the full 2-year tests but your primary reason for selling was a job relocation, health issue, or an unforeseeable event, you may still qualify for a partial exclusion. Probably not relevant for a planned sale years later but good to have in the back of your head.

Moved out of my place in January 2021 and sold in February 2026. Thought I had a clean exclusion. Turned out I didn't, because the 5-year lookback from my February 2026 close date only went back to February 2021. January 2021 was just outside, so none of my 24 residence months counted. Missing it was stressful.

That's exactly how tight the math can get. Closing about two years earlier and you'd have kept the exclusion.

Yep. Moving my close date earlier by a couple of weeks wouldn't have helped either; I'd have needed to sell about two years sooner.

Start from your expected closing date, step back exactly 5 years to the same date, and see whether your 24 months of actual residence fall anywhere in that window. If you're close to the edge, running different closing dates through the same math shows you which one keeps you safely inside. The residence months don't have to be the most recent 24, they just have to be somewhere in that 5-year stretch.

This is the clearest framing I've seen. So I should literally try March 1 close, April 1 close, etc., and see which ones still pull my March 2017–March 2022 residence inside the lookback window.

Exactly. And build in a buffer because closings slip. If you're right on the edge, closing a month late could cost you the whole exclusion.

Don't forget to reduce your basis by any gain you postponed from a home sold before May 7, 1997 under the old rollover rules. Publication 523 Worksheet 2 lists that as a basis adjustment. Very few people have this issue anymore but if you've owned homes for 30 years it could come up and affect what your actual gain is.

I'd strongly suggest pulling together a written timeline: date of purchase, date you moved in, date you moved out, date you converted to rental, projected closing date. Then do the 5-year lookback from that closing date. If the numbers are large, pay for an hour with a CPA before you decide when to list. The cost of getting it wrong is much larger than a consulting fee.

That's the plan. I'm going to map it out for a few different closing date scenarios and then bring it to a CPA before we list. Appreciate everyone's help here.

Worth noting the basis question too. Your basis in the home isn't just what you paid. It includes capital improvements you made over the years, minus the depreciation you deducted during the rental period. A higher basis means a lower gain, which matters a lot if you end up only partially inside the exclusion or over the exclusion ceiling.

We did a full kitchen remodel and a new roof while we lived there. So those additions increase the basis and reduce the gain. That's good to know before we figure out how much is actually at stake.

Related question: does the 2-year bar on reusing the exclusion reset if enough time has passed? Like if I sold a prior home 3 years ago and used the exclusion then, am I clear for this sale?

Yes, Publication 523 says you can't use the exclusion if you excluded gain on another home sold within the 2-year period before this sale. If your prior sale was more than 2 years ago, that bar doesn't apply.

Good, that's what I figured but wanted to confirm it. My prior sale was 3 years back so I should be in the clear on that front.

Came back to add: if you end up getting a 1099-S and reporting on Form 8949 with code H, make sure the proceeds in column (d) match exactly what's on the 1099-S. Even if the whole gain is excluded, a mismatch between the 1099-S amount and your Form 8949 column (d) can generate a notice from the IRS asking you to explain the difference. Keep the closing disclosure handy.

Good practical point. The closing disclosure will have the exact number and I should use that to verify what the title company puts on the 1099-S before I file.