To avoid having to empty your bladder during a marathon, change your prerace hydration strategy. According to the American College of Sports Medicine position statement on exercise and fluid replacement, "When hydrating prior to exercise the individual should slowly drink beverages (for example, ~5–7 mLIkgj1 per body weight) at least 4 h before the exercise task. If the individual does not produce urine, or the urine is dark or highly concentrated, s/he should slowly drink more beverage (for example, another ~3–5 mLIkgj1) about 2 h before the event. By hydrating several hours prior to exercise there is sufficient time for urine output to return towards normal before starting the event. Consuming beverages with sodium (20–50 mEqILj1) and/or small amounts of salted snacks or sodium-containing foods at meals will help to stimulate thirst and retain the consumed fluids.
"Prehydrating with beverages, if needed, should be initiated at least several hours before the exercise task to enable fluid absorption and allow urine output to return toward normal levels. "
MY COMMENT: If you have to pee during the race, you probably drank too much too close to the start time. Begin drinking 4 hours before your race, and by T-minus 2 hours your urine should be clear. Drink very little after that up until minutes before your event begins (I like to drink 8-10 ounces with a 100 calorie gel right before the start).