early pregnancy

When is it possible to take a pregnancy test ? Like how many weeks after having sex