Once an egg is released, it can only survive for up to 24 hours, but since sperm can survive for up to 5 days, your fertility window is approximately 6 days long as you can have sex several days before you ovulate and still get pregnant. The best time to have sex is in the days leading up to ovulation and the day of ovulation itself. This fertile window may vary between women and even your cycles, so a simple way to know this is to take an ovulation test.