
386 N.W.2d 352 (1986)
STATE of Minnesota, Respondent,
v.
William DOYLE, Appellant.
No. C4-86-208.
Court of Appeals of Minnesota.
May 6, 1986.
*353 Hubert H. Humphrey, III, Atty. Gen., Thomas Foley, Ramsey Co. Atty., Steven C. DeCoster, Asst. Co. Atty., St. Paul, for respondent.
C. Paul Jones, Public Defender, Mark F. Anderson, Asst. Public Defender, Minneapolis, for appellant.
Considered and decided by PARKER, P.J., and LANSING and CRIPPEN, JJ., with oral argument waived.

OPINION
PARKER, Judge.
This appeal is from a 44-month sentence for burglary imposed on November 12, 1985. The trial court gave appellant William Doyle jail credit only for the time spent in custody from October 30, 1985, when he pled guilty. Doyle argues he should have received credit for time served prior to his plea. We affirm in part and reverse in part.

FACTS
On August 1, 1985, residences at 1355 and 1359 Sherburne Avenue in St. Paul, Minnesota, were burglarized. Later that day, Doyle was arrested in connection with the burglary at 1359 Sherburne and charged with second-degree burglary in violation of Minn.Stat. §§ 609.581 and .582, subd. 2(a) (1984). He posted bail and was released on August 2, 1985.
Doyle was arrested for fencing property stolen from the residence at 1355 Sherburne on August 6, 1985, and was charged with two counts of felony theft in violation of Minn.Stat. §§ 609.52, subds. 2(1) and 3(2), and 609.05 (1984). He posted bail and was released on August 8, 1985.
On August 15, 1985, Doyle was arrested under a Minnesota Department of Corrections warrant for violating parole. He had been incarcerated from January 1983 until June 1985 for a prior felony offense and was on supervised release. The violation report specified that he violated parole when he failed to report to his parole officer, within 24 hours, the arrests for burglary of 1359 Sherburne and for fencing property stolen from 1355 Sherburne and when a finding of probable cause was issued on both complaints.
At a parole revocation hearing on August 28, 1985, he was found to be in violation of parole. A decision as to whether parole should be revoked was continued until after disposition of the burglary and theft charges. He remained in custody at Ramsey County jail pursuant to a Department of Corrections detainer.
On October 30, 1985, Doyle pled guilty to an amended charge of third-degree burglary on the charges stemming from the burglary at 1359 Sherburne. The plea agreement further provided that (1) the theft counts based on his fencing of property stolen from 1355 Sherburne would be dismissed at sentencing; (2) he would receive jail credit for time served after October 30, and he reserved the right to argue he should receive jail credit for other time served; (3) the State would request the maximum sentence under the guidelines; and (4) any sentence imposed would be concurrent to time served under "any parole violation or revocation that may occur as a result of this conviction."
On November 12, 1985, Doyle was sentenced to 44 months with jail credit only for time served from October 30, 1985. He appeals under Minn.R.Crim.P. 28.05, contending he is entitled to jail credit for the periods from August 1-2, from August 6-8, and from August 15 to October 30, 1985. The State agrees Doyle is entitled to credit for time spent in custody from August 1-2, but urges that no credit be given for the other two periods of time.

ISSUE
Is appellant entitled to credit for time spent in jail from August 6-8 and August 15 to October 30, when he pled guilty?


*354 ANALYSIS
The matter of granting jail credit is not discretionary with the trial court. Minn.R. Crim.P. 27.03, subd. 4(B), mandates that when a criminal sentence is imposed, the trial court shall
assure that the record accurately reflects all time spent in custody in connection with the offense or behavorial incident for which sentence is imposed. Such time shall be automatically deducted from the sentence * * *.
Id. (emphasis added); see also Minn.Stat. § 609.145, subd. 2 (1984) (credit must be given for time served between conviction and sentencing).
It is undisputed that Doyle is entitled to credit for August 1-2, when he was arrested and charged with the burglary of 1359 Sherburne, the offense to which he eventually pled guilty and was sentenced. He was therefore improperly denied jail credit for August 1-2.
Doyle was in custody from August 6-8, however, following his arrest for fencing property stolen from a different residence, 1355 Sherburne. He was charged with two counts of felony theft, which were dismissed pursuant to the plea agreement. His sentence was imposed for the burglary offense. The time he spent in jail from August 6-8 was therefore not connected to the "offense for which sentence [was] imposed." Credit for August 6-8 was correctly denied.
Finally, Doyle argues he is entitled to credit for time spent in jail from August 15, when he was arrested for violating parole, until October 30, when he pled guilty. He remained in custody during this time under a Department of Corrections detainer pending disposition of the burglary and theft charges. He was found in violation of parole, but a decision as to whether to revoke parole was delayed until disposition of these charges.
The facts of this case are similar to those of State v. Mattson, 376 N.W.2d 413 (Minn. 1985), aff'g as modified, 356 N.W.2d 391 (Minn.Ct.App.1984). Mattson was arrested in Minnesota and charged with criminal sexual activity. After being released on bond, he surrendered to Wisconsin authorities on a parole violation warrant which had been issued when Wisconsin authorities discovered he had been charged with a new crime in Minnesota. Mattson's parole was revoked based on the Minnesota charges, and he remained in Wisconsin on a "parole hold" until December 5, 1983, when he was sentenced in Minnesota. The trial court credited Mattson's sentence with all time served prior to trial, including the time spent in Wisconsin. On appeal this court determined that Mattson was not entitled to credit for the Wisconsin jail time. The supreme court disagreed, concluding "[i]t is * * * beyond question that the Minnesota offense was the sole reason for defendant's Wisconsin incarceration." Id., 376 N.W.2d at 416.
Doyle was in custody from August 15 to October 30 for violating parole when he failed to report the burglary and theft arrests to his parole officer. He was kept in jail after the revocation hearing because a decision as to whether his parole would be revoked was postponed until after disposition of those charges. Doyle was therefore being held in connection with the burglary charge for which sentence was eventually imposed.
Moreover, the plea agreement provided that Doyle's sentence was to be served concurrently with time required as a result of any parole violation or revocation. To deny him credit for time spent in jail for violating parole might constitute a breach of the plea agreement. It would also be unfair to deny him credit for this time, which was spent in jail because a decision on his parole revocation was delayed until disposition of the current charges. See State v. Patricelli, 357 N.W.2d 89, 94 (Minn.1984); State v. Anderson, 378 N.W.2d 632, 635 (Minn.Ct.App.1985).

DECISION
The trial court correctly denied appellant credit for time served in jail from August 6-8. The trial court erred in denying appellant *355 credit for time served in jail from August 1-2 and August 15 to October 30.
Affirmed in part and reversed in part.
