We can know the sex of the child before birth itself by studying the chromosomes of the foetus.
The embryo is surounded by a fluid called amniotic fluid. It has few fetal cells in it. The amniotic fluid is taken out a little.The fluid has cells of the baby and they are tested to know the sex of the child.But knowing the sex of the child before birth is punishable by law.