Deductions & credits

It does not need to be consecutive, but because you moved in after the rental period, the will only get a prorated exclusion and therefore pay taxes on PART of the gain.  TurboTax will walk you through that situation.