וַיֹּ֣אמֶר אֵלַי֮ אַל־תִּירָ֣א דָנִיֵּאל֒ כִּ֣י ׀ מִן־הַיּ֣וֹם הָרִאשׁ֗וֹן אֲשֶׁ֨ר נָתַ֧תָּ אֶֽת־לִבְּךָ֛ לְהָבִ֧ין וּלְהִתְעַנּ֛וֹת לִפְנֵ֥י אֱלֹהֶ֖יךָ נִשְׁמְע֣וּ דְבָרֶ֑יךָ וַאֲנִי־בָ֖אתִי בִּדְבָרֶֽיךָ׃
At sinabi niya sa akin: “Huwag kang matakot, Daniel, sapagkat mula sa unang araw na itinuon mo ang iyong puso upang makaunawa at upang pahirapan ang iyong sarili sa pag-aayuno sa harap ng iyong Diyos, dininig na ang iyong mga salita, at dahil sa iyong mga salita ay naparito ako.
Mishneh Torah, Fasts
Just like the community fasts about their troubles, so [too] does the individual fast about his trouble. How is this? See that [if] he had a sick person or one lost in the wilderness or imprisoned in a prison, he should fast for him and request mercy in his prayer. And (on these fasts), he should say, "Answer us, etc.," in every prayer that he prays. But he should not fast on Shabbat, nor on festivals nor on Rosh Chodesh, nor on Chanukkah or Purim.
Kitzur Shulchan Arukh
It is a mitzvah, for every Jewish community, when they are beset with trouble, God forbid, to fast and pray to Hashem, blessed is His Name, (for rescue) from their troubles. But if the time is not appropriate for fasting, for instance, if people are fleeing, they are not permitted to fast, lest their strength will be sapped. However they should resolve to fast a certain number of fast days, when they are saved. This will be counted as if they were now fasting, as we find concerning Daniel, about whom it is written, "He said to me, 'Do not be afraid, Daniel; for from the day you resolved to understand and to fast before your God, your words were heard'" (Daniel 10:12).