A person could probably hold their urine in for 30 hours before they can no longer hold it back and then wet their pants without being able to do anything about it.
Now you should never hold your urine in for that long or even longer than a few hours since you risk getting bladder infections, bladder cancer, becoming incontinent and even risk getting kidney disease.
It's much better for your overall health to go relieve your pee as soon as you feel the urge to go and avoid holding your pee in for too long.