At how many months or weeks pregnant can you find out the gender?

Candice

At how many months or weeks pregnant can you find out the gender of your baby on a ultrasound? What’s the earliest it can be detected?