The Messenger of Allah ﷺ said, "Whoever takes an oath and then sees that something else is better than it, let him abandon his oath, do what is better, and make expiation for it."
أخبرنا هناد بن السري عن أبي بكر بن عياش عن عبد العزيز بن رفيع عن تميم بن طرفة
قال رسول الله ﷺ من حلف على يمين فرأى غيرها خيرا منها فليدع يمينه وليأت الذي هو خير وليكفرها
Muslim graded it sahih, in the book of Oaths, chapter on the recommendation for one who swears an oath and then sees something better than it, etc., no. 1651, from the hadith of Abdul-Aziz via the same chain, and it is also in Al-Kubra, no. 4728.