Yeah once you get up towards forty you're going to be hopping out of bed at least once a night for a quick slash. Especially if you're on certain medications.
I'm in my mid-40's and this trick has worked for me for over a decade, including just a couple of weeks ago. (@mjklin - I'm not an MD and I'm not being flippant, if you're already having problems in this area you might want to see a urologist about it. Nocturia is a problem for relatively few people our age - https://en.wikipedia.org/wiki/Nocturia#Prevalence)
I can't use the water trick day in and day out, because I get habituated to it and end up sleeping through my bathroom visit.
I also have to be careful about how much I drink; too much and the bathroom visit happens in the middle of the night and back to sleep I go. But 10-12 oz consumed rapidly within 10 minutes before my head hits the pillow seems to be the sweet spot.