عن أبي طَرِيف عدي بن حاتم رضي الله عنه مرفوعاً: «مَن حَلَف على يَمِين ثم رأى أَتقَى لله مِنها فَلْيَأت التَّقوَى».
The Hadīth states that anyone takes an oath to do or not to do something, and then he sees that doing something else is better and more pleasing to Allah than abiding by the oath, then he is recommended to break the oath and do what is better. If the oath is related to something that is obligatory to be done or to be abandoned, such as swearing to abandon the prayer or to drink wine; in this case, he must break his oath and do what is more pleasing to Allah.
In other words, he must do what is obligatory and abandon what is forbidden.
Download for free and never miss a prayer again