Sahih Muslim Book 033, Hadith Number 6391.

Chapter : The growth of a child in the womb of a mother and his destiny in regard to his livelihood, his deeds. both good and evil.

This hadith has been reported on the authority of A'mash with the same chain of transmitters and in the hadith transmitted on the authority of Waki' (the words are): "The creation of any one of you is like this that (semen) is collected in the womb of the mother for forty nights," and in the hadith transmitted on the authority of Shu'ba (the words are): "Forty nights and forty days." And in the hadith transmitted on the authority of Jarir and 'Isa (the words are): "Forty days."