To exclude the gain on the sale of a personal residence (up to $250,000 for a single taxpayer and $500,000 for married taxpayers filing jointly) you will need to live in the house for two of the five years leading up to the sale. If you moved out of the house in May 2020 than you would either need to sell it or move back into it before May 2023. In your case, the five year period will run from May 2018 through April 2023 and you will have lived in the house for two years from May 2018 through May 2020. Tax Aspects of Home Ownership: Selling a Home provides a good summary of this rule plus other important points regarding the profit from the sale of a personal residence.
**Say "Thanks" by clicking the thumb icon in a post
**Mark the post that answers your question by clicking on "Mark as Best Answer"