Abu Hurairah reported,

A man became distressed in the presence of the Prophet ﷺ, then returned to his family and found that the children had gone to sleep. His wife brought him his food, but he swore an oath not to eat because of 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, then sees that something else is better than it, let him do what is better and make expiation for his oath."

Azami 7105

Sahih

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

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

الأعظمي 7105صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Oaths and vows
Chapter
Faith
Section
Breaking an oath before expiation
Numbering
Jami al-Kamil 7105 (2nd edition)
Azami 7105