I'm NOT married right now but i'm selling my house for 300k profit. would I have to get married BEFORE the sale of the house in order to qualify for the 500k exception?

OR do i have to be married by the end of 2019 AND file jointly next year?