All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
Fasting an obligatory day is not valid unless one makes the intention by night, be it the month of Ramadan, making up for a missed day of Ramadan or fasting a vow. As the whole day must be fasted, a previous intention has to be made like other acts of worship. Concerning the voluntary fasting, the scholars differed whether or not the intention has to be made by night.
The first opinion: The opinion of the majority of scholars who consider that the intention does not have to be made by night. However, they are of the view that it is a condition that no nullifiers of fasting should have occurred from Fajr time until the time one makes the intention to fast. Their evidence about this is the narration reported by Muslim and others that 'Aa'ishah said: "The Prophet entered once to my room and said: "Do you have any food? I replied: "No." So the Prophet said: "In this case I am going to fast."
The second opinion: The opinion of some scholars who are of the view that it is a condition to have the intention whether it is an obligatory fasting or a voluntary fasting. This is the view of Maaliki School. Their evidence is the narration reported by Ahmad in his Musnad, and Ibn Khuzaymah in his authentic narration, and others, may Allaah have mercy on all of them, that Hafsah the mother of the believers, narrated that the Prophet said: "Whoever has not made the intention before Fajr to fast, it is as if he has not fasted."
The majority of scholars are of the view that the narration of Hafsah if it is authentic, is general whereby the narration of 'Aa'ishah is specific to voluntary fasting.
Allaah knows best.