
661 N.W.2d 154 (2003)
STATE of Iowa, Appellee,
v.
Chadwick Eugene TRADER, Appellant.
No. 01-1763.
Supreme Court of Iowa.
May 7, 2003.
*155 Linda Del Gallo, State Appellate Defender, and Martha J. Lucey, Assistant State Appellate Defender, for appellant.
Thomas J. Miller, Attorney General, Kristin Mueller, Assistant Attorney General, John P. Sarcone, County Attorney, and Jaki L. Livingston, Assistant County Attorney, for appellee.
CARTER, Justice.
Defendant, Chadwick E. Trader, appeals from an order reconsidering and increasing his original sentence for third-degree burglary involving an unattended motor vehicle. At the time the trial information was filed, the offense to which defendant ultimately pled guilty was a class "D" felony. However, prior to the entry of his plea and subsequent sentencing, that statute was amended so as to provide that the offense was an aggravated misdemeanor if the subject of the burglary was an unattended motor vehicle.
At the time of sentencing, the court was cognizant of the amendment and sentenced defendant for conviction of an aggravated misdemeanor. Later, when the State called the court's attention to the fact that defendant had a prior conviction for burglary of a motor vehicle, the court reconsidered and increased defendant's sentence to that provided for a class "D" felony. The court of appeals affirmed the district court's increased punishment. Upon reviewing the record and considering the arguments presented, we vacate the decision of the court of appeals and reverse the judgment of the district court.
The defendant was charged with third-degree burglary involving an unattended motor vehicle committed on May 23, 2001. At the time the trial information was filed, that offense was a class "D" felony. The statute was soon amended, effective July 1, 2001. The amended statute provided:
1. All burglary which is not burglary in the first degree or burglary in the second degree is burglary in the third degree. Burglary in the third degree is a class "D" felony, except as provided in subsection 2.
2. Burglary in the third degree involving a burglary of an unoccupied motor vehicle or motor truck as defined in section 321.1, or a vessel defined in section *156 462A.2, is an aggravated misdemeanor for a first offense. A second or subsequent conviction under this subsection is punishable under subsection 1.
2001 Iowa Acts ch. 165, § 1 (amending Iowa Code § 713.6A). Defendant pled guilty to the offense on July 20, 2001, and was sentenced on August 30, 2001, both of those dates falling after the amended statute became effective.
Iowa Code section 4.13 provides:
If the penalty, forfeiture, or punishment for any offense is reduced by a re-enactment, revision, or amendment of a statute, the penalty, forfeiture, or punishment if not already imposed shall be imposed according to the statute as amended.
We have recognized that an amendment to a sentencing statute that reduces the penalty for an offense committed prior to its effective date must be applied if the statute is effective at the time of sentencing. State v. Chrisman, 514 N.W.2d 57, 61 (Iowa 1994); State v. Bousman, 278 N.W.2d 15, 16 (Iowa 1979). We agree with that interpretation of the statute. If the amendment to section 713.6A reduced the punishment for the offense with which defendant was charged, he was entitled to be sentenced in accordance with the newly enacted law. At defendant's original sentencing, the court agreed that the offense was an aggravated misdemeanor and sentenced defendant accordingly. Later, the State informed the court that defendant had a prior conviction for the same offense. More than two months later, the court, relying on the second sentence of paragraph 2 of the amended statute, reconsidered and increased defendant's sentence to that provided for a class "D" felony.
In upholding the district court's upward revision of defendant's sentence, the court of appeals concluded that the amended statute did not reduce the penalty for defendant's offense because of the fact that he committed that offense as a second offender. That conclusion fails to take into consideration that, at the time of defendant's guilty plea and sentencing, the court was not empowered to sentence defendant under the enhancement provision of the revised statute because defendant had not been charged as a prior offender in the trial information. Our Iowa Rules of Criminal Procedure provide:
If the offense charged is one for which the defendant, if convicted, will be subject by reason of the Code to an increased penalty because of prior convictions, the allegation of such convictions, if any, shall be contained in the indictment.
Iowa R.Crim. P. 2.6(5). We have recognized that this procedure extends the requirements of Apprendi v. New Jersey, 530 U.S. 466, 120 S.Ct. 2348, 147 L.Ed.2d 435 (2000), to sentencing enhancements based on prior convictions. State v. Jacobs, 644 N.W.2d 695, 698 (Iowa 2001). Consequently, if the State intended to take advantage of the enhancement provision of the amended statute, it was incumbent on it to amend the trial information to allege the prior offense and then either establish that offense at trial on a supplemental information or obtain a plea of guilty to an enhanced charge of third-degree burglary.
Based on the trial information that existed at the time of defendant's plea and sentencing, the proper sentence was that provided for an aggravated misdemeanor. That was the sentence imposed at the original sentencing proceeding. It was a legal sentence, and the district court erred in altering it more than two months later.
Defendant was granted probation by the sentencing judge, but was required to spend time at the Fort Des Moines *157 Residential Correctional Facility. In the court's sentencing order, it was provided that the defendant should not receive credit for time served at that residential correctional facility if his probation was revoked. That portion of the sentence was also in error because Iowa Code section 907.3(3) provides that "[a] person so committed [to a community correctional residential treatment facility] who has probation revoked shall be given credit for such time served." In resentencing defendant, the court shall grant the credit which that statute requires.
Based on our conclusions, we vacate the decision of the court of appeals, reverse the district court's sentencing order, and remand the case to that court for the resentencing of defendant for conviction of an aggravated misdemeanor.
DECISION OF COURT OF APPEALS VACATED; DISTRICT COURT JUDGMENT REVERSED AND REMANDED.
