Regarding the recital of HaMapil, some are concerned that perhaps they will not fall asleep and their berachah will have been said in vain. However, in practice, the fact that the Chachamim instituted reciting HaMapil means that they were not concerned about this. The blessing is a thanksgiving berachah to Hashem about sleep, and even for a person who does not succeed in falling asleep, the expression of thanks is not made in vain (Chayei Adam 35:4). Still, l’chatchilah, the Chachamim instituted the recital of this berachah for those who intend to sleep, and therefore one who has no intention of sleeping does not recite HaMapil on that particular night.
The HaMapil blessing is not recited on daytime sleep, although some say that it is good to say Viyhi No’am before a nap taken during the day (Mishnah Berurah 239:8 and see Bei’ur Halachah “Samuch”). HaMapil is also not recited on a temporary sleep at night. However, sleeping in one’s bed for half an hour or more is considered a regular sleep (Eshel Avraham 239; Beit Baruch 35:10). A person who went to sleep at night after reciting HaMapil, arose later to attend to certain matters, and then went back to sleep, does not repeat the HaMapil blessing, since HaMapil is only recited once a night (Beit Baruch 35:9; Piskei Teshuvot 239:1, note 4). One who fell asleep without reciting HaMapil, and woke up in the middle of the night with the intention to continue sleeping, must recite the berachah before falling asleep again. If he does not wish to get up from his bed and wash his hands, he may rub his hands on his blanket and then recite it (Shulchan Aruch Orach Chaim 4:23; Mishnah Berurah 61; unlike Piskei Teshuvot 239:1 who maintains that washing one’s hands is a requirement).
There are those who learned, based on the Kabbalah of the Arizal, that only a person who goes to sleep before chatzot (halachic midnight) recites the HaMapil blessing, and whoever goes to sleep after chatzot does not. Hence, many Sephardim are accustomed to reciting HaMapil without Shem u’Malchut (Hashem’s Name) when going to sleep after chatzot (Kaf HaChaim 239:8; see Yechaveh Da’at, part 4, pp. 122-124). However, according to the Ashkenazic minhag and that of some Sephardim, as long as one goes to sleep before amud hashachar, HaMapil is recited.