In order to qualify for the capital gains tax exclusion, you must have lived in the property as your primary residence for at least 2 years (730 days) of the last 5 years (1826 days) you owned it, counting back from the closing date of the sale. Since it was not your primary residence for at least 2 of the last 5 years you owned it, you do not qualify for the exclusion.
There are situations where one can qualify for a partial exclusion. For example, if you were forced to move as a requirement of employment or military PCS orders. Other exceptions for a partion exemption are covered in IRS Publication 523 at https://www.irs.gov/pub/irs-pdf/p523.pdf starting on page 6.