Depreciation is one of my favorite topics to discuss, as it is truly the 8th wonder of the world as far as real estate investors are concerned.
First off, understand this: Depreciation is a TAX concept that has no bearing in the real world. It's simply a way the Govt invented to prevent investors from taking the entire Cost of Good (i.e. the building we just bought) and expensing it against our income in year 1, then still having a ton of leftover expense to carry forward into future years. Uncle Sam wants his money NOW, so he only lets us deduct a portion of our expense each year.
Here's where it starts to get "funny"...
According to the depreciation logic, the building we own is gradually wearing out over time and becoming less valuable, until finally in year 27.5 + 1 day is it a worthless pile of junk with $0 value.
However, we know that isn't the case. We are keeping our property in good condition, and in most cases over 27.5 years the property is worth far more than what we paid for it.
As an added bonus, we get to write off all of our expenses making sure that the property stays in good condition and increases in value. So we get a double deduction: 1) for depreciation (building is falling apart) and 2) costs to prevent the building from falling apart.
As a further added bonus, once you sell the property, the depreciation magically resets. So that 29.5 + 1 day old piece of property that is worthless in the eyes on the IRS becomes fully valuable again as if it were built fresh today for whatever the sale price is as of the day of sale. It doesn't matter that it has already been fully depreciated once, twice, or 5 times.
If you paid $10,000 for it 27.5 years ago, then today it is worthless according to the IRS. If you sell it tomorrow for $500,000, now the IRS says it is worth $500,000.
MAGIC! This is why depreciation is a TAX concept and has no basis in reality. It's just a book-keeping game, nothing more.
So now that was a really long way to get to your answer. Depreciation resets--magically--whenever the property is sold to someone else regardless of whether it's 1 day old or 100 years old.
And now the added bonus x2... if you die and leave the property to your heirs, they will take possession under current tax law with depreciation wiped out. Again, magically it's as if the property were never depreciated. This is one time you sidestep (legally) the depreciation recapture tax. MAGIC!
This is how families build vast, multi-generational wealth: accounting tricks and IRS magic.