Because sperm can survive for a few days inside your body, having sex before ovulation can help you get pregnant. The ideal window is 3 days: ovulation day and the 2 days before it.
Eggs need to be fertilized within 24 hours after they’re released from ovaries, so having sex a day or 2 later may be too late.
If you track your ovulation based on the calendar, you might want to have sex a few days before and after the expected date, because the actual day can shift from month to month. Ovulation predictor kits can help you get the timing even more exact.