I remember learning the Gemara in Brachos that says until 40 days from conception one can pray for the child to be a specific gender.
Does this mean one can pray until 40 days from mikva night if one knows that they are pregnant (as that night the conception may have happened)?
Would one have to stop praying at shkia of the 39th day?
The 40 days are counted from the mikva night, (unless they didn’t have relations then). One can pray for the full 40 days, the 40th day included.
Hashem should send you children that will be talmedei chachamim and yirei shomayim, and everything should go well.