Devarim / Deuteronomy 9:18 · Remez
וָאֶתְנַפַּל לִפְנֵי יְהוָה כָּרִאשֹׁנָה אַרְבָּעִים יוֹם וְאַרְבָּעִים לַיְלָה לֶחֶם לֹא אָכַלְתִּי וּמַיִם לֹא שָׁתִיתִי עַל כָּל־חַטַּאתְכֶם אֲשֶׁר חֲטָאתֶם לַעֲשׂוֹת הָרַע בְּעֵינֵי יְהוָה לְהַכְעִיסוֹ׃
And I fell down before the Eternal, as at the first, forty days and forty nights: I ate no bread and drank no water, because of all your sin which you had sinned, in doing what was evil in the eyes of the Eternal, to provoke Him.
Remez רֶמֶז
The time of a prayer
You ask for something, and still no answer comes. How much longer must you wait? The midrashim count the days and years after which a prayer was answered.
Midrash Lekach Tov: Moshe (Moses) went without food and drink for a hundred and twenty days in a row, three times forty. The last forty ended on Yom Kippur, and that is why in some places the shofar is blown from the first day of the month of Elul. Midrash Aggadah: every prayer has its own time. One waits a hundred years for an answer, another two years, a third forty days, like the prayer of Moshe. And sometimes the answer comes before a person has finished speaking.
How Midrash Lekach Tov and Midrash Aggadah explain it
Midrash Lekach Tov And I fell down before the Eternal, as at the first
This teaches that Moshe went without food and drink for a hundred and twenty days in a row: the first forty, for it says "as at the first", another forty when he lay prostrate, and the forty days of the last tablets. The first ended on the seventeenth of Tammuz, the middle ones on the first day of the month of Elul, and the last on Yom Kippur. That is why in some places it is the custom to blow the shofar from the first day of the month of Elul.
Midrash Aggadah And it was at the end of two years (Bereshit / Genesis 41:1)
There is a prayer that is answered after a hundred years. From where? From Avraham (Abraham), as it is said: "And Avraham was a hundred years old" (Bereshit / Genesis 21:5). There is a prayer that is answered after ninety years, from Sarah, as it is said: "Shall Sarah, who is ninety years old, give birth?" (Bereshit / Genesis 17:17). There is one after eighty years, as it is said: "And Moshe was eighty years old" (Shemot / Exodus 7:7). There is one after seventy years, as it is said: "When seventy years are completed for Babylon" (Yirmeyahu / Jeremiah 29:10). There is one after sixty years, as it is said: "And Yitzchak (Isaac) was sixty years old" (Bereshit / Genesis 25:26). There is one after fifty years, from Shmuel (Samuel): Chana (Hannah) said "and he shall stay there forever" (Shmuel I / I Samuel 1:22), and the service of the Levites lasts only until fifty years, as it is said: "And from the age of fifty years" (Bamidbar / Numbers 8:25). There is one after forty years, as it is said: "And Yitzchak was forty years old" (Bereshit / Genesis 25:20). After thirty years, as it is said: "And Yosef (Joseph) was thirty years old" (Bereshit / Genesis 41:46). After twenty years, as it is said: "These twenty years I have been with you" (Bereshit / Genesis 31:38). After ten years, from Hagar, as it is said: "At the end of ten years" (Bereshit / Genesis 16:3). After a year, from the Shunammite woman, as it is said: "At this season next year you will embrace a son" (Melachim II / II Kings 4:16).
There is a prayer that is answered after forty days, as it is said: "And I fell down before the Eternal, as at the first, forty days" (Devarim / Deuteronomy 9:18). After ten days, from Naval (Nabal), as it is said: "And about ten days later the Eternal struck Naval" (Shmuel I / I Samuel 25:38). After seven days, as it is said: "And Miriam was shut out of the camp seven days" (Bamidbar / Numbers 12:15). After three days, as it is said: "And Yonah (Jonah) prayed" (Yonah / Jonah 2:2). After an hour, as it is said: "Answer me, Eternal, answer me" (Melachim I / I Kings 18:37). And there is a prayer that has not yet left the mouth of the one praying, and the answer has already come, as it is said: "And the Eternal said to Moshe: 'Why do you cry out to Me?'" (Shemot / Exodus 14:15). But the prayer of Yosef waited two years, as it is said: "And it was at the end of two years" (Bereshit / Genesis 41:1).
Takeaway
Three periods of forty days: on the mountain for the first tablets (Shemot / Exodus 24:18), in prayer after the golden calf (Devarim / Deuteronomy 9:18, 9:25), and on the mountain for the second tablets (Devarim / Deuteronomy 10:10).
The verses Midrash Aggadah brings speak of prayers that came true: Yitzchak was born when Avraham was a hundred years old (Bereshit / Genesis 21:5), and Yosef came out of prison after two years (Bereshit / Genesis 41:1, 41:14).