shenatayim yamim - two years
The words shenatayim yamim mean two years - not two days. These years were counted from the time Yosef interpreted the dreams of Pharaoh's two courtiers who were imprisoned with him. On this occasion Pharaoh had a dream. See that the Torah speaks of shenatayim "two years" was was the need to add the word yamim "days"? When the Torah wanted to tell us that there had been two years of famine it wrote, ki zeh shenatayim haraav "for these last two years which have been famine," (Bereishit 45:6) it did not bother to add the word yamim. The point the Torah wanted us to know here by adding the word yamim is that it was precisely two years to the day after Yosef had interpreted the dreams in jail that Pharaoh dreamt his dream of the cows and the ears of corn.
According to a Midrashic approach in Tanchuma Miketz 1 the wording of the Torah here may teach us the following: The words miketz shenatayim yamim are a reminder of Iyov 28:3, "He sets bounds for darkness, to every limit man probes, to rocks in deepest darkness." Everything G-d decrees is finite, has a limit. Even the rains emerge after a time-frame has been assigned for them. G-d determines the time frame and the quantity for rain on earth at the beginning of the year. if the Jewish people keep G-d's laws these rains descend to make the plantings of the Jewish farmer grow by descending upon these fields and orchards in the appropriate quantities at the appropriate time of year. If the Jewish people fail to observe G-d's mitzvot, He does not withhold such rains; rather such rains will descend in areas and at times when they do not fulfill the purpose of making the Jewish farmer bring in a good harvest. This is what was implied in the verse in Iyov 28:3, i.e. that G-d had set a time limit to the "darkness" the Jewish people experienced when enslaved in Egypt. This is why the Torah in Shemot 12:41 spoke of a "an end" when it reported "it was at the end of 430 years, on exactly that day that all the hosets of G-d departed from Egypt." Just as the day of the departure of the Jewish people had been predetermined by G-d, so Yosef's release from prison had been predetermined by G-d.