Fetal gender determination is suprisingly accurate, according to this study: Accuracy of sonographic fetal gender determination: predictions made by sonographers during routine obstetric ultrasound scans
The results state the following:
Results confirmed 100% accuracy in predictions made after 14 weeks
gestation. The overall success rate in the first trimester group
(11–14 weeks) was 75%. When excluding those scans where a prediction
could not be made, success rates increased to 91%.
Results were less accurate for fetuses younger than 12 weeks, with an overall success
rate of 54%. Male fetuses under 13 weeks were more likely to have
gender incorrectly or unable to be assigned. After 13 weeks, success
rates for correctly predicting males exceeded that of female fetuses.
Statistical differences were noted in the success rates of individual
sonographers.
Provided the scan is done after 14 weeks, accuracy is very good, but can vary between sonographers.
Currently in the UK antenatal care schedule, most women will have an initial scan at 8-14 weeks and then an anomaly scan at 18-20 weeks gestation.