Riyad as-Salihin, Book 1, Hadith 575 (In-Book)

'Abdullah bin 'Umar (May Allah be pleased with them) reported: Messenger of Allah said, "It is the duty of a Muslim who has something which is to be given as a bequest not to have it for two nights without executing a written will."[Al-Bukhari and Muslim].In the narration of Muslim it is narrated as 'three nights'. Ibn 'Umar (May Allah be pleased with them) said: Since I heard the Messenger of Allah say this, I have never spent a night without having my will with me.

وعنه أن رسول الله صلى الله عليه وسلم قال‏:‏ “ ما حق امرئ مسلم ، له شئ يوصي فيه ، يبيت ليلتين إلا ووصيته مكتوبة عنده” ‏(‏‏(‏متفق عليه‏)‏‏)‏ هذا لفظ البخاري‏.‏ وفى رواية لمسلم” يبيت ثلاث ليال‏:‏ قال ابن عمر‏:‏ ما مرت على ليلة منذ سمعت رسول الله صلى الله عليه وسلم قال ذلك إلا وعندي وصيتي‏.‏

sunnah.com