How long should you withhold water pre-surgery

I’ve always been curious about the best practices for withholding water before surgery. I was taught that it depends on the procedure, but is there a general rule for most situations? It seems like a crucial detail for patient safety, and I want to make sure I’m getting it right.

‌⁠‍⁠​‍​‍‌⁠‌​​‍​‍​⁠‍‍​‍​‍‌⁠‌‍‌‍‌‌‌⁠‌​‌‍‌‌‌⁠​‍‌‍‍‌‌‍⁠‍‌‍​‌‌⁠​‍‌⁠‍‌‌‍​‌‌⁠​⁠‌⁠​⁠‌‍‍‌‌⁠​⁠‌⁠‌​‌‍​‌‌‍⁠‍‌⁠‌​​‍​‍​‍⁠​​‍​‍‌‍‍⁠​‍​‍​⁠‍‍​‍​‍‌‍⁠‍‌‍‌‌‌⁠‌⁠‌‌⁠⁠‌⁠‌​‌‍⁠⁠‌⁠​​‌‍‍‌‌‍​⁠​‍​‍​‍⁠​​‍​‍‌‍‍‌‌‍‌​​‍​‍​⁠‍‍​‍​‍‌‍⁠‍‌‍‌‌‌⁠‌⁠​‍​‍​‍⁠​​‍​‍‌‍‌​​‍​‍​⁠‍‍​‍​‍​⁠​‍​⁠​​​⁠​‍​⁠‌‍​⁠​‌​⁠​‌​⁠​‌​⁠​‍​‍​‍​‍⁠​​‍​‍‌‍‍​​‍​‍​⁠‍‍​‍​‍‌‍​⁠​⁠‌⁠‌‍​⁠‌​​‌‌‌‌​‌‍⁠‌​⁠‍​‌‌​​‌⁠​​​⁠‌⁠​⁠‍​‌‍⁠​‌‌​​‌‍​‍‌‍⁠‍‌‍‍​​‍​‍‌⁠⁠‌​