Did the Sahaabah (may Allah be pleased with them) fast on the day of Badr?
Question

did the sahabas at the time of the battle of Badr fast the holy month of Ramadan?
when was ramadan made as an obligation to fast?
Praise be to Allah.Firstly:
Fasting the month of Ramadan was made obligatory in 2 AH, and the Prophet (blessings and peace of Allah be upon him) fasted nine Ramadans.
See fatwa no. 37649
Secondly:
The Prophet (blessings and peace of Allah be upon him) used to instruct his companions (may Allah be pleased with them) to break their fast when they drew close to their enemy, so that they would have more strength to fight. Breaking the fast when meeting the enemy in battle is one of the means of strength.
Muslim (1120) narrated that Abu Sa‘eed al-Khudri (may Allah be pleased with him) said: We travelled with the Messenger of Allah (blessings and peace of Allah be upon him) to Makkah when we were fasting. We made a stop, and the Messenger of Allah (blessings and peace of Allah be upon him) said: “You have drawn near to your enemy, and breaking the fast will make you stronger.” This was a concession, so some of us fasted and some did not. Then we made another stop and he said: “In the morning, you are going to meet your enemy. And breaking the fast will make you stronger, so break the fast.” He emphasized it (the second time), so we broke the fast..
At-Tirmidhi (714) and Ahmad (140) narrated via Ibn Luhay‘ah, from Yazeed ibn Abi Habeeb, from Ma‘mar ibn Abi Habeebah, from Ibn al-Musayyab, that he asked him about fasting when travelling, and he narrated that ‘Umar ibn al-Khattaab said: We went out on two campaigns with the Prophet (blessings and peace of Allah be upon him) in Ramadan, the day of Badr and the conquest (of Makkah), and we broke the fast during both.
It was classed as da‘eef by al-Albaani in Da‘eef at-Tirmidhi.
But its isnaad was classed as jayyid by al-Haafiz Ibn Katheer (may Allah have mercy on him) in Musnad al-Faarooq (1/279). The commentators on al-Musnad said:
It is a qawiy hadith. ‘Abdullah ibn Luhay‘ah had a poor memory, but it was narrated from him by Qutaybah ibn Sa‘eed. And the narration of Qutaybah from him is good and valid. Sa‘eed ibn al-Musayyab heard from ‘Umar, and according to the view of those who say that he did not hear from him, his mursal reports are still saheeh. Abu Taalib said: I said to Ahmad ibn Hanbal: Do reports of Sa‘eed from ‘Umar count as proof? He said: In our view they count as proof; he saw ‘Umar and heard from him. If Sa‘eed did not accept reports from ‘Umar than who would accept them?
Similarly, it was classed as hasan by al-Mullah ‘Ali al-Qaari in Sharh Musnad Abu Haneefah (1/399)
Al-Haafiz Ibn Rajab al-Hanbali (may Allah have mercy on him) stated that definitively and said: Ramadan was made obligatory for the Prophet (blessings and peace of Allah be upon him) in 2 AH, which was the first Ramadan that he fasted, and the Muslims fasted it with him. Then the Prophet (blessings and peace of Allah be upon him) went out in pursuit of a caravan of Quraysh that had come from Syria heading towards Madinah, on the Saturday 12th of Ramadan, and he broke his fast on his way to meet it. Ibn al-Musayyab said : ‘Umar said: We went out on two campaigns with the Prophet (blessings and peace of Allah be upon him) in Ramadan, the day of Badr and the conquest (of Makkah), and we broke the fast during both. End quote.
Lataa’if al-Ma‘aarif (p. 177)
What is more likely to be the case is that the Sahaabah (may Allah be pleased with them) broke the fast when they set out to meet the enemy on the day of Badr, because that would be of greater help to them in their jihad against their enemy.
See also question no. 12641
Fourthly:
What is prescribed with regard to qiyaam al-layl (voluntary prayers at night) – during Ramadan and otherwise – is to offer them two rak‘ahs by two, because the Prophet (blessings and peace of Allah be upon him) said: “The night prayers are two (rak‘ahs) by two.”
Narrated by al-Bukhaari (993) and Muslim (749).
The majority of scholars are of the view that it is permissible to pray qiyaam al-layl four rak‘ahs by four.
It is not prescribed to pray qiyaam with three rak‘ahs, except at the end, when one may pray three consecutive rak‘ahs, saying the tashahhud at the end, then say the tasleem.
If a person gets up for a third rak‘ah by mistake when praying Taraweeh, he should sit back down, recite the tashahhud and tasleem, then do the two prostrations of forgetfulness (sujood as-sahw), then say the tasleem again.
If he gets up for a third rak‘ah by mistake and completes it, then he should make it even-numbered by adding a fourth rak‘ah. Doing this was regarded as permissible by some of the fuqaha’. Whoever follows this view and thinks that it is valid, or follows a scholar who says that, then his prayer is valid.
See fatwa no. 141381
And Allah knows best.