It is essential to make the intention to fast the month of Ramadan at night, before Fajr. It is not sufficient to start fasting it that day without the intention. Whoever finds out at the time of Duha that today it is Ramadan and makes the intention of fasting has to refrain from eating until sunset, and he also has to make up that day, because it was narrated by Ibn ‘Umar from Hafsah (may Allaah be pleased with her) that the Prophet (peace and blessings of Allaah be upon him) said: “Whoever does not have the intention of fasting before Fajr, there is no fast for him.” Narrated by Imam Ahmad, the authors of al-Sunan, Ibn Khuzaymah and Ibn Hibbaan; they classed it as saheeh and marfoo’.
This is with regard to obligatory fasts. With regard to naafil fasts it is permissible to make the intention to fast on the day, if you have not eaten or drunk or had intercourse after Fajr, because it was proven in the hadeeth of ‘Aa’ishah (may Allaah be pleased with her) that the Prophet (peace and blessings of Allaah be upon him) entered upon her one day at duha time and said, “Do you have anything (any food)?” She said, “No.” He said, “Then I am fasting.” Narrated by Muslim in his Saheeh.
And Allaah is the Source of strength. May Allaah send blessings and peace upon our Prophet Muhammad and his family and companions.