I was told at 15wks and was confirmed at 20wks that she was right about the gender
Best educated guess can be around 12-15 weeks. Weeks 18 and on they can give you a definite answer.
You can get a blood test done at around 10 weeks that can tell you the gender. We call it the harmony test where I'm from.
The sneak peak blood test can tell you at 9 weeks. A 3D/4D can tell you starting around 14 weeks and are quite accurate, I did one and it was very obvious. Most of them also come with a garuntee that of for whatever reason they don't feel confident in awnser they'll reschedule in a month to check again for free. You also normally find out at the 20 week anatomy scan.
We were told at 15 weeks and confirmed at 20.