I bought my house on 3/31/2016 and moved out on 7/31/2018. when do I need to sell the house by to avoid capital gains tax?

I am currently renting the house out and want to sell it soon. really want to know how best to reduce my tax burden.