Pregnant??

How long after sex can you take a pregnacy test and it be accurate? I just had sex last night but I also just got off my period so If I wait to see if my period it'll be a month. Can I take a test before my missed period and it be accurate? How soon?