With the recent invention of the ultrasound, a lot about the baby can be told prenatally. One of the side effects of this is that the parents can know the gender of the child beforehand. This has caused a split in expecting parents: some want to know and others don't. This is when this trope gets involved.
In modern settings, this trope starts when the doctor is about to offer the baby's gender to the couple. Typically, one parent will insist on knowing the gender while the other adamantly insists on a surprise, "so long as the baby is healthy." This can start an argument, or the parent who wants to know to come up with wacky schemes to learn the baby's gender.
However, even before this, the question of a baby's gender may come up. Perhaps there are certain old wives' tales that will predict the gender (ie. If the pendulum starts spinning clock-wise, it's a boy). If there are young children, they may discuss the benefits between having a baby brother or a baby sister. In these cases, it usually happens not too long before the actual birth.
- In a Flashback episode of The Simpsons when Marge is preganant with Maggie, Bart is sure that the baby will be a boy because, as he tells Lisa, it always goes "boy, girl, boy, girl."
- A minor plot point in Charmed while Piper is pregnant with Wyatt for a while. Before then, all the children born in the Halliwell family had been female. In particular, it took Grams her own episode before she accepted her great-grandchild.
- In the song "Pregnant Women Are Smug", the answer to this question is, "oh, we know but we aren't telling."
- In the Star Trek: The Next Generation episode "Genesis", Dr. Crusher asked Data if he wanted to know the gender of Spot's kittens. He mentions the surprise element, at which point we learn that Nurse Ogawa was also pregnant.
- How I Met Your Mother plays this both ways:
- When trying to conceive their first child, Lily and Marshall try different Old Wives' Tales to affect the gender of the baby.
- Later, when the gender of the child is known, Lily and Marshall agree to keep it a mystery, but Barney finds out and tortures them until they admit that they really DO want to know. It's a girl.
- For the fifth child on Good Luck Charlie, Bob wants to know the gender, but Amy wants it kept a mystery. Wacky Hijinks ensue.