Kenneth Robert Ferguson, of The Old Fort, pleaded guilty to disorderly behaviour and resisting police on September 8, last year.
Derry Magistrates Court heard police escorted the 27-year-old to get treatment for the wounds on his back.
He was abusive to police during his time in the hospital. The officers then received instructions to arrest him as two others had sustained stab wounds at a party.
Ferguson’s behaviour was ‘explosive and aggressive’ in front of other patients.
He then attempted to tangle his arms around a chair to prevent police from restraining him.
Defence counsel Nicki Rountree said her client was ‘frustrated’ and didn’t understand what was happening on this night.
She told the court Ferguson believed police were treating him as the victim, but then seized his clothes and arrested him.
Ms Rountree said the 27-year-old accepts his behaviour was ‘completely unacceptable’ and he is ‘ashamed’ by it.
District Judge Barney McElholm jailed Ferguson for four months.
However, the judge agreed to release the defendant on bail pending an appeal of the sentence.