Abdullah bin Amr bin As reported,

The Messenger of Allah ﷺ said to me, "Have I not been informed that you stand in prayer all night and fast all day?"I said, "Yes."He said, "If you do that, your eyes will become sunken and your soul will grow weary. Fast three days from every month, for that is like fasting the entire year."I said, "I find within myself," Masaar said, meaning strength.He said, "Then fast the fast of Dawud عليه السلام. He used to fast one day and break his fast the next, and he never fled when he met the enemy."

Bukhari 3419

Sahih

حدثنا خلاد بن يحيى حدثنا مسعر حدثنا حبيب بن أبي ثابت عن أبي العباس

عن عبد الله بن عمرو بن العاص قال

قال لي رسول الله ﷺ ألم أنبأ أنك تقوم الليل وتصوم النهار فقلت نعم فقال فإنك إذا فعلت ذلك هجمت العين ونفهت النفس صم من كل شهر ثلاثة أيام فذلك صوم الدهر أو كصوم الدهر قلت إني أجد بي قال مسعر يعني قوة قال فصم صوم داود عليه السلام وكان يصوم يوما ويفطر يوما ولا يفر إذا لاقى

البخاري 3419صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Hadiths of the prophets
Chapter
Saying of Allah the Exalted, "And We gave Dawud the Zabur"
Numbering
Darussalam 3419
Bukhari 3419