We have to bear in mind the fact that fasting is one of the basic pillars of Islam. The Prophet (peace and blessings be upon him) said, “Islam is built upon five pillars: testifying that there is no true god except Allah and that Muhammad is the Messenger of Allah, performing Prayer, paying the Zakah, making the pilgrimage to the Sacred House (Hajj), and fasting the month of Ramadan.” (Reported by Al-Bukhari)
Scholars unanimously agree that falling into swoon does not remove the obligation of fasting from a person who is legally fit to observe fasting, even if that unconsciousness lasts for the whole month of Ramadan. They support their view with the verse that reads: (And whosoever of you is present, let him fast the month.) (Al-Baqarah 2:185) However, Al-Hasan Al-Basri adopted a different view.
As for a person who makes the intention for fasting at night and then falls into syncope during the day, there is a difference of opinion regarding him. While some scholars say that his fasting is not valid, others say that it is still valid. The correct view is that he should make up for that day so as to be in the safe side. However, if he gains consciousness even for a moment during the day and makes the intention for fasting, then his fasting is totally accepted.
Shedding more light on the issue, we would like to quote the following from the Kuwaiti Encyclopedia of Jurisprudence:
All scholars are of the view that fainting does not exempt the person from fasting. In this way, if a person faints for the whole month and then sobers up, he has to make up for all the days he missed. The jurists further comment on this saying that fainting may necessitate delaying fasting but not ignoring it altogether. To exempt someone from fasting, the person concerned must be either not physically well or religiously not responsible for his deeds.
A person who intends to fast during night then faints during the day but gets conscious even for one moment and makes the intention for fasting during it, his fasting is acceptable. As regards he who makes the intention during the night but falls into swoon for the whole day, his fasting is not acceptable according to Shafi`i and Hanbali scholars. They quote the following Qudsi (sacred) hadith in support of their view: “Almighty Allah says: ‘Fasting is Mine and it is I who give reward for it, for he (a fasting person) abstains from food and drink for My sake.” In this hadith, it is mentioned that a person abstains from food and drink for Allah’s sake. A fainted person lacks such a characteristic and thus his fasting is invalid. Abu Hanifah, however, says that his fasting is valid because he has made the intention while still awake and fainting, in this case, resembles sleeping in case of a sleeping person.