1,359. Committing in Advance to a Fast
Hilchos Taaniyos 1:10 If a person did not commit to a fast before sunset on the preceding day, it is not considered a fast. One commits to a fast as follows: after davening mincha, one says, "Tomorrow I will fast" with the intention to do so. Even though he will eat at night, this does not diminish his commitment to fast. Similarly, if a person committed to fast for three or four consecutive days and he accepts this fast upon himself, the fact that he eats each night in between these fasts does not diminish his commitment. One need not re-state his commitment on the afternoon before each day of the fast. Hilchos Taaniyos 1:11
Let’s say that someone resolves to fast on the next day, he fasts as planned, then on the night after the fast he decides to continue the fast on the next day. This is not considered a fast, because he did not commit to it while it was still day. This would be the case even if he continued fasting overnight. It goes without saying that if he ate and drank at night, then decided to fast when he woke up in the morning, that it is not considered a fast at all.