
Sperms have different speed and life expectancy. Sperms carrying the male chromosome travel fast (towards the egg) but die off quickly, sometimes even on the way to it, i.e. they may never reach the egg.
However, for the female chromosomes it is the other way round, they are slow but "sturdy".
Therefore, it is logical that you must have intercourse directly on the day of ovulation or just after to conceive a boy. For a girl, about 48-24 hours before ovulation will be correct usually.
The correct time of ovulation can be most accurately tested by looking at the hormonal changes during your cycle. The easiest and most accurate way is by looking at your saliva under a microscope first thing every day on waking up. There are several such devices available, in handy 'lipstick size', and very easy to use.
In some, more rare cases, men will only carry one kind of chromosome, i.e. only one gender will be possible. Or sperms are too slow, i.e. will result in girls (can be genetic, due to stress, frequent flying or even diet). These can all easily be tested by sperm test.
Remember that it is the sperms of three months ago that are responsible for actual conception!
Hope this sheds some light on the many myths out there. Good luck!