Dean Smith, 27, of Treorchy, Wales, went to Barclays to change his address and saw the money in the tills, the Merthyr Crown Court heard.
He returned half an hour later to raid the bank dressed in a "terrible disguise" of sunglasses and wearing socks over his shoes, BBC reported.
The cashier refused to give him money and Smith ran away empty handed.
Smith admitted attempted robbery and carrying a bladed weapon.
Also Read
"She could see he was holding a bread knife across his body as he demanded all the cash to be handed over," prosecutor Rachel Knight said.
"He was not shouting. He was rushed but not angry or agitated. He sounded desperate. Ms Stockton raised the alarm by pressing the panic button," she said.
Smith has been jailed for two-and-a-half years.
Defending Smith, Stephen Jeary, said: "He told the police it was stupid and he was very sorry but he was desperate for money.