If the property was your primary residence for at least 24 months of the last 60 months you owned it, then you qualify for the capital gains tax exclusion. The 24 months do not have to be consecutive either.
The only way you qualify for a partial exclusion is if you had to move due to official government orders. See IRS Topic 701 at https://www.irs.gov/taxtopics/tc701 for more information.