Abu Salama ibn ‘Abdurrahman reported from ‘Abdullah ibn ‘Amr that the Prophet, upon whom be peace, said to him: ‘I have been informed that you stay up in prayer during the night and fast during the day. ‘Abdullah answered: “Yes, O Messenger of Allah.” The Prophet said: “Fast and do not fast, pray and sleep, for your body, your wife, and your guests have a right upon you. It is sufficient for you to fast three days a month.” ‘Abdullah said: “I wanted to be stricter on myself and I said: “O Messenger of Allah, I have the strength to do more.” The Prophet said: “Then fast three days a week.” ‘Abdullah said: “I have the strength to do more!” The Prophet said: “Fast the fast of the Prophet David and do not do more than that!” ‘Abdullah inquired: “And what was the fast of David?” The Prophet replied: “He would fast one day and then not fast the next.” This is recorded by Ahmad and others.
Ahmad also related from ‘Abdullah ibn ‘Amr that the Prophet said: “The fast most loved by Allah is the fast of David, and the most loved prayer is the prayer of David. He would sleep half the night, pray for a third of the night, and then sleep during the last sixth of the night. He would also fast one day and then eat on the next.”