Giants right-hander Mark Melancon confirmed that he would undergo surgery to alleviate chronic exertional compartment syndrome in his right forearm.

The question is not whether he would have the procedure, but when.

“I guess that’s the best way to put it: I need surgery, and I’m day to day,” Melancon said. “I’m trying to last as long as I can.”

Melancon said he wants to continue pitching through September and delay the surgery until after the season, for his own reasons as well as to aid a bullpen that he is being paid $62 million to anchor. But he acknowledged that the procedure would be scheduled sooner if he struggles to bounce back from outings or be competitive.

Giants manager Bruce Bochy also hinted in recent days that Melancon’s date with the scalpel could be imminent.

“It’s day to day — literally day to day,” Melancon said.

The part that Melancon will not contest: he needs surgery. He has dealt all season with what the club has described as a strained pronator muscle, which is located where the forearm meets the elbow. The 32-year-old former All-Star closer revealed that he has been diagnosed with exertional compartment syndrome, a condition in which the sheath that covers the muscle does not allow it to expand when worked.

Surgery would involve releasing the lacertus fibrosus and has a recovery time of two to three months.