
649 P.2d 504 (1982)
98 N.M. 436
STATE of New Mexico, Plaintiff-Appellant,
v.
Raymond RAMZY, Defendant-Appellee.
No. 5677.
Court of Appeals of New Mexico.
July 20, 1982.
Jeff Bingaman, Atty. Gen., Barbara F. Green, Asst. Atty. Gen., Santa Fe, for plaintiff-appellant.
John B. Bigelow, Chief Public Defender, William P. Slattery, Asst. Appellate Defender, Santa Fe, Michael Lilley, Las Cruces, N.M., for defendant-appellee.

OPINION
LOPEZ, Judge.
The state appeals an amended judgment which gave a pre-sentence confinement credit of 59 days to the defendant in a case involving the charge of criminal sexual penetration in the third degree contrary to § 30-9-11(C), N.M.S.A. 1978, and designated as Case Two in this opinion. We affirm.
The issue on appeal is whether the trial court correctly decided that the time served by the defendant between December 29, 1981, and February 25, 1982, should be credited toward his conviction in Case Two. Based on stipulated facts, the trial court concluded that as a matter of law the defendant had been held in official confinement for the period in question and was entitled to pre-sentence confinement credit against the sentence in Case Two for fifty-nine days pursuant to § 31-20-12, N.M.S.A. 1978 (Repl.Pamp. 1981). Section 31-20-12 states:
A person held in official confinement on suspicion or charges of the commission of a felony shall, upon conviction of that or a lesser included offense, be given credit for the period spent in presentence confinement against any sentence finally imposed for that offense.
The following facts are based on the stipulated facts of the parties which the trial court adopted and other documents in the district court file. On June 26, 1981, the *505 defendant was found guilty by jury of aggravated burglary and aggravated assault contrary to § 30-3-5(C), N.M.S.A. 1978, and § 30-3-2, N.M.S.A. 1978, respectively. These convictions are referred to as Case One. The defendant was sentenced to the state penitentiary for concurrent terms of 3 years for the aggravated battery conviction and 18 months for the aggravated assault conviction. An appeal was taken from these convictions and the defendant remained at liberty on appeal bond.
On November 7, 1981, while free on appeal bond in Case One, the defendant was arrested and incarcerated on the charges in Case Two. Following a preliminary hearing and a reduction in bond, the defendant posted bond and was released on these Case Two charges on December 3, 1981.
On December 28, 1981, the appeal bond in Case One was revoked because of the Case Two charges. Upon revocation defendant was immediately incarcerated to begin the service of his sentence in Case One. On December 29, 1981, the defendant was arraigned in district court on Case Two charges. His Case Two bond was raised at this time to an amount which he apparently could not post.
On February 25, 1982, the defendant entered a plea of nolo contendere in Case Two to the charge of criminal sexual penetration in the third degree. All other charges originally filed in Case Two were dismissed. Pursuant to this plea the defendant was sentenced to two years in the state penitentiary, to be served consecutively to the Case One sentence. He was at that time given credit in Case Two for 26 days pre-sentence confinement.
On March 10, 1982, the defendant's trial counsel filed a Motion to Correct and Modify Sentence. The defendant claimed that he was entitled to credit for presentence confinement between December 29, 1981, and February 25, 1982, since he had been held in official confinement in Case Two during that period. The district court granted the motion and amended the judgment in Case Two by ordering a total credit for pre-sentence confinement of 85 days. The state then initiated this appeal; State v. Santillanes, 96 N.M. 482, 632 P.2d 359 (Ct.App. 1980); State v. Aguilar, 95 N.M. 578, 624 P.2d 520 (1981). The argument of the state is based on the premise that the defendant received dual credit for the 59 days, which is incompatible with consecutive sentences.
Section 31-20-12 has been addressed by our courts. The statute has been strictly interpreted with resulting benefits to the defendant. Pre-sentence confinement on a felony charge has been held to include official confinement at the State Hospital. State v. La Badie, 87 N.M. 391, 534 P.2d 483 (Ct.App. 1975). In State v. Baca, 87 N.M. 495, 535 P.2d 1346 (Ct.App. 1975), this court emphasized that credit is to be given against "any sentence," minimum or maximum, imposed by the trial court. See also State v. Martinez, 92 N.M. 256, 586 P.2d 1085 (1978). The language of the statute is mandatory. In State v. Brewton, 83 N.M. 50, 487 P.2d 1355 (Ct.App. 1971), the defendant pled guilty to a misdemeanor committed in a state penitentiary while serving a prior sentence. He sought and was denied credit for 28 days which elapsed between the day he was served with a warrant for his arrest on the misdemeanor charge and the day he pled guilty to that charge. This court denied relief because the defendant was not in fact being held in confinement pursuant to the misdemeanor charge. He was instead being held pursuant to a prior conviction on another case for which he was serving time at the New Mexico State Penitentiary. In State v. Barefield, 92 N.M. 768, 595 P.2d 406 (Ct.App. 1979), the court was faced with three cases involving complicated facts. Addressing the issue of credit this court said:
Section 31-20-12, supra, provides for credit for presentence confinement against the sentence imposed upon conviction of the offense charged or a lesser included offense. If the confinement was not in connection with the offense charged, § 30-20-12, supra, does not authorize a credit. State v. Brewton, 83 N.M. 50, 487 P.2d 1355 (Ct.App. 1971).
* * * * * *

*506 We cannot, however, say that defendant was not confined in Case 3. After ruling that defendant was incompetent in Case 3, the trial court ordered defendant returned to the penitentiary because he was dangerous and had escaped from the State Hospital. This seems to indicate that in light of his incompetency, defendant would have been confined at the State Hospital, in Case 3, but for the fact that he was dangerous. The record being ambiguous, defendant may raise the issue of credit on his Case 3 sentences by appropriate motion. See State v. Murray, 81 N.M. 445, 468 P.2d 416 (Ct.App. 1970). If defendant, in fact, was confined on Case 3 charges, he is entitled to credit for that presentence confinement even though he was also confined, at the same time, in Case 1. Mancinone v. Warden, Connecticut State Prison, 162 Conn. 430, 294 A.2d 564 (1972).
The language in Barefield, supra, indicates that the decisive factor in allowing credit for pre-sentence confinement in a case is whether the confinement was actually related to the charges of that particular case. It is not necessary that the confinement be related exclusively to the charges in question.
In People v. Simpson, 120 Cal. App.3d 772, 174 Cal. Rptr. 790 (1981), the California court addressed the issue of credit for pre-sentence confinement. In that case the defendant was on parole when he was arrested and jailed. A parole hold was placed on the same day. When his parole was revoked, the defendant was given credit for his parole revocation term from October 29, 1979. He was sentenced on the current charge on March 5, 1980, and also requested credit against his current term from October 29, 1979, even though he had accrued custodial credit against his revoked parole term. The court gave credit for the requested pre-sentence confinement. The applicable section at that time is similar in content to the New Mexico statute: "`For the purposes of this section credit shall be given only where the custody to be credited is attributable to proceedings related to the same conduct for which the defendant has been convicted.'" (Emphasis in original.)
The court reasoned that the California statute did not prohibit giving credit for both the revoked parole term and the new term.
In the case at bar the defendant was not confined when Case Two occurred. Case Two triggered and caused the revocation of the appeal bond in Case One. He was unable to meet the high bond required in Case Two. Defendant's incarceration and confinement for the period in question was undoubtedly partly, if not totally, caused by Case Two charges. There is sufficient connection between Case Two and the confinement between December 29, 1981, and February 25, 1982, to warrant credit for such incarceration and confinement, even though he was at the same time in custody due to the revocation of the appeal bond in Case One. We hold that the trial court properly gave credit for the pre-sentence confinement pursuant to § 31-20-12.
The order and judgment of the trial court is affirmed.
IT IS SO ORDERED.
WOOD and NEAL, JJ., concur.
