Abdullah bin Amr bin As reported,

The Prophet ﷺ received word that I was fasting continuously and praying through the night. He either sent for me or I met him, and he asked, "Have I not been told that you fast without breaking your fast and pray without sleeping? Fast and break your fast, pray and sleep, for your eyes have a right over you, and your soul and your family have a right over you."I said, "I am strong enough for that."He said, "Then fast the fast of Dawud عليه السلام."I asked, "And how was that?"He replied, "He used to fast one day and break his fast the next, and he never fled when he met the enemy in battle."I said, "Who will grant me the ability to do this, Prophet of Allah?"Ata said, I do not know how the mention of perpetual fasting came up, but the Prophet ﷺ said, "He has not fasted who fasts perpetually," saying it twice.

Bukhari 1977

Sahih

حدثنا عمرو بن علي أخبرنا أبو عاصم عن ابن جريج سمعت عطاء أن أبا العباس الشاعر أخبره أنه سمع

عبد الله بن عمرو رضي الله عنهما

بلغ النبي ﷺ أني أسرد الصوم وأصلي الليل فإما أرسل إلي وإما لقيته فقال ألم أخبر أنك تصوم ولا تفطر وتصلي فصم وأفطر وقم ونم فإن لعينك عليك حظا وإن لنفسك وأهلك عليك حظا قال إني لأقوى لذلك قال فصم صيام داود عليه السلام قال وكيف قال كان يصوم يوما ويفطر يوما ولا يفر إذا لاقى قال من لي بهذه يا نبي الله قال عطاء لا أدري كيف ذكر صيام الأبد قال النبي ﷺ لا صام من صام الأبد مرتين

البخاري 1977صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Fasting
Chapter
Right of the family regarding fasting
Numbering
Darussalam 1977
Bukhari 1977