Although this sounds simple, we all know that nothing in the tax laws is that easy. So long as either spouse meets this requirement, the exclusion of gain applies.
Marital status is determined on the date the house is sold.
In a divorce proceeding where one spouse gets the house, that spouse can sell it even before the two years is up because any time that the former spouse owned the property will be credited to the total time. The exclusion is generally applicable once every two years. This new law applies to all principal residences. If you claim a mobile home or boat as your principal residence, the law also applies. Many homeowners have periodically sold and traded up over the years.