Are all improvements that I made to my home during the the time that I owned it counted to determine the adjusted cost basis or do I just those made for the tax year?

Can I only count improvements made to my home in the tax year that I sold it? Also, does it matter that I already included some of the improvements as a rental expense for the tax year that I began renting out part of my home? I stopped renting out part of my home in 2017.