Deductions & credits

the details are in publication 523.

https://www.irs.gov/forms-pubs/about-publication-523

 

To use the $250,000/$500,000 exclusion, you must have owned the home at least 2 years AND used the home as your main home for at least 2 years -- the time that you were moved out and living in home #2 still counts for the ownership test but does not count for the main residence test.