Understand that no matter what, you will pay tax on the recaptured depreciation. There's no way out of that. Doesn't matter if you qualify for the gain exclusion or not. You *will* be taxed on recaptured depreciation.
Generally, you qualify for the exclusion in its' entirety, or your don't. But there are exceptions.
For example, if you are active duty military and are required to move under orders before the 2 years are up, then you qualify for a partial exclusion. Also, if you move as a condition of employment or continued employment, that will qualify you for a prorated exclusion also. But if you don't qualify for an exclusion from the 2 year requirement, then it's all or nothing.