Carl
Level 15

Deductions & credits

The house must have been your primary residence for at least 730 days of the last 1526 days you owned it. The closing date of your sale does not count as a day having lived in the property. If you moved out say, 1 week before the closing date, then it's perfectly possible the property was not your primary residence for the full 730 days.
Rarely does someone vacate their residence just one day prior to closing on the sale. I've only seen that when there's a lease back agreement as part of the sales contract. But even then, the day count stops one day before the closing date, because as of that date the owner no longer owns the property.