Abu Hurairah reported,

A man stayed late with the Prophet ﷺ, then returned to his family and found that the children had fallen asleep. His wife brought him his food, but he swore he would not eat, out of consideration for his children. Then he reconsidered and ate. He came to the Messenger of Allah ﷺ and mentioned this to him.The Messenger of Allah ﷺ said, "Whoever swears an oath and then sees that something else is better than it, let him do what is better and make expiation for his oath."

Muslim 4271

Sahih

حدثني زهير بن حرب حدثنا مروان بن معاوية الفزاري أخبرنا يزيد بن كيسان عن أبي حازم

عن أبي هريرة قال

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

مسلم 4271صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Oaths
Chapter
Recommendation for one who swore an oath then saw something better to do what is better and expiate for his oath
Numbering
Darussalam 4271
Muslim 4271