Neither of these codes states anything specific regarding gestational age. If O31.2 was only referring to a pregnancy over 20 weeks, it would not list a code for the first trimester. You would think if a fetus was aborted, there would be some sort of bleeding. I guess, in my opinion, if it was a intrauterine death the body may absorb that fetus, ie; vanishing fetus.
I guess you could use either code depending on the situation.