
233 Cal.App.3d 1061 (1991)
285 Cal. Rptr. 6
THE PEOPLE, Plaintiff and Respondent,
v.
DAVID LACEBAL, Defendant and Appellant.
Docket No. F015170.
Court of Appeals of California, Fifth District.
August 27, 1991.
*1062 COUNSEL
Karen H. Salant, under appointment by the Court of Appeal, for Defendant and Appellant.
Daniel E. Lungren, Attorney General, George Williamson, Chief Assistant Attorney General, Robert R. Anderson, Assistant Attorney General, and Roger E. Venturi, Deputy Attorney General, for Plaintiff and Respondent.
OPINION
BEST, P.J.
On April 17, 1990, a complaint (No. 4345-90) was filed in the Borden Judicial District of Madera County charging defendant with burglary in violation of Penal Code section 459.[1]
On May 2, 1990, defendant was sentenced to 16 months in state prison in an unrelated case (Super. Ct. No. 8834).
*1063 On October 10, 1990, defendant entered a conditional plea of guilty to violation of section 496, subdivision 1, in resolution of complaint No. 4345-90, and was certified to the superior court for sentencing (Super. Ct. No. 9310).
On November 29, 1990, the superior court sentenced defendant to state prison for the principal term of two years in case No. 9310. The court then resentenced defendant to two years in state prison in case No. 8834, suspended sixteen months pursuant to section 1170.1 and imposed the remaining eight months consecutive to the principal term in case No. 9310.
Defendant apparently remained in local custody from the date of his arrest on the burglary charge, April 12, 1990, to the date of sentencing, November 29, 1990. The court credited defendant with 31 days against his sentence, 21 days for actual time served (from Apr. 12, 1990, the date of his arrest, to May 2, 1990, the date of his sentence, in case No. 8834) plus 10 days custody credits.
The facts underlying defendant's convictions are irrelevant to the issue raised on appeal and will be omitted.
The report of the probation officer reflects defendant was on parole for a prior burglary conviction when on January 1, 1990, he was arrested for petty theft which ultimately resulted in case No. 8834, petty theft with a prior, a felony (§ 666). Defendant was out of custody on bail in case No. 8834 and was also on parole from the prior burglary conviction when, on April 12, 1990, he was arrested for residential burglary in what later became case No. 9310. A parole hold was imposed on the day of his arrest, April 12, 1990, and defendant remained in local custody pending sentencing in both cases.
(1) The sole issue presented on this appeal is whether the trial court erred in refusing defendant credit for the time served in custody from May 2, 1990, through November 29, 1990, in case No. 8834.

DISCUSSION
Section 669 provides in part:
"When any person is convicted of two or more crimes, whether in the same proceeding or court or in different proceedings or courts, and whether by judgment rendered by the same judge or by different judges, the second or other subsequent judgment upon which sentence is ordered to be executed *1064 shall direct whether the terms of imprisonment or any of them to which he is sentenced shall run concurrently or consecutively; ..."
California Rules of Court, rule 452 provides in part:
"If a determinate sentence is imposed pursuant to section 1170.1(a) consecutive to one or more determinate sentences imposed previously in the same court or in other courts, the court in the current case shall pronounce a single aggregate term, as defined in section 1170.1(a), stating the result of combining the previous and current sentences. In those situations:
"(1) The sentences on all determinately sentenced counts in all of the cases on which a sentence was or is being imposed shall be combined as though they were all counts in the current case.
"(2) The judge in the current case shall make a new determination of which count, in the combined cases, represents the principal term, as defined in section 1170.1(a)."
Insofar as pertinent to this case, section 1170.1, subdivision (a) provides that the subordinate term for a consecutive offense shall consist of one-third of the middle term of imprisonment prescribed for that offense.
California Rules of Court, rule 472 provides in part:
"At the time of sentencing, the court shall cause to be recorded on the judgment or commitment the total time in custody to be credited upon the sentence under Penal Code section 2900.5."
Section 2900.5 reads in pertinent part:
"[Credit for time in custody prior to commencement of sentence]... (b) 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. Credit shall be given only once for a single period of custody attributable to multiple offenses for which a consecutive sentence is imposed."
This court observed in People v. Adrian (1987) 191 Cal. App.3d 868 at page 875 [236 Cal. Rptr. 685], "As we have noted, in what is surely an understatement, `[c]redit determination is not a simple matter.' (People v. Chew (1985) 172 Cal. App.3d 45, 49....)" Nevertheless, in our view, defendant's claim is correct in light of our Supreme Court's analysis in People v. Riolo (1983) 33 Cal.3d 223 [188 Cal. Rptr. 371, 655 P.2d 723]. *1065 Riolo was convicted of burglary and sentenced to state prison for the upper term of three years. Earlier grants of probation in two prior cases were revoked and eight-month terms imposed. Although made concurrent to each other, the eight-month terms were designated as consecutive subordinate terms to the principal term of three years imposed for the burglary. As here, the trial court expressly denied credit for time served in connection with the two prior convictions. The Supreme Court explained, "Once the trial court has determined that the sentence for an offense will be consecutive to a principal term, the court must impose the consecutive term defined by section 1170.1, subdivision (a). That term is the `term of imprisonment' for the offense, and, therefore, the term from which credits must be deducted.[5]" (Id. at p. 227.) In footnote number 5 the Supreme Court further explained:
"California Rules of Court, rule 449, requires the trial court to compute the full term, including enhancements, for each conviction independently. The rule directs the trial court to `stay execution' of whatever portion of the full term cannot be imposed because of statutory limitations on consecutive sentences. [¶] This system may have some administrative value. However, the administrative concept that a portion of the consecutive term is `stayed' does not alter the fact that the statutes define the sentence on the consecutive offense as one-third the middle base term. Neither the hypothetical full term for the offense nor the concept of a `stay' of part of the `term' appears in the statutes. As long as the consecutive term remains subordinate to a principal term, its term of imprisonment is the period of time amounting to one-third the middle base term." (People v. Riolo, supra, 33 Cal.3d at p. 227, italics in original.) The Supreme Court further pointed out that section 2900.5, subdivision (c) provides in part, "`For the purposes of [section 2900.5], "term of imprisonment" includes any period of imprisonment imposed as a condition of probation or otherwise ordered by a court in imposing or suspending the imposition of any sentence, and also includes any term of imprisonment, including any period of imprisonment prior to release on parole and any period of imprisonment and parole, prior to discharge....'" (People v. Riolo, supra, 33 Cal.3d at p. 227.) The court concluded that Riolo was, by the express terms of the statutes, clearly entitled to have the time served on the prior offenses as a condition of probation credited against the consecutive eight-month term. (Id. at pp. 228-229.)
Here, the trial court, in the proper exercise of its discretion, correctly combined the sentences in case No. 9310 and in the previous case No. 8834, designating the sentence in case No. 9310 as the principal term and imposing a consecutive subordinate term for case No. 8834. The court also correctly awarded presentence custody credits of 31 days against the sentence imposed *1066 in case No. 9310. However, the court erroneously refused to credit the time in custody attributable to case No. 8834 against the consecutive subordinate term of eight months imposed for case No. 8834.
"In the case of multiple proceedings leading to terms which are consolidated pursuant to section 669, the `attributable' limitation still applies. As previously mentioned, credits are not reallocated: they remain assigned only to the proceedings in which they were earned. Therefore, if the last court orders consecutive sentences and the credits earned on the terms ordered to run consecutive exceed the resulting one-third of middle base terms imposed, the consecutive terms are `served,' but the excess credits are not available to reduce the unrelated full base term. [Citations.]" (People v. Adrian, supra, 191 Cal. App.3d 868, 877; § 1170, subd. (a)(2).)
Defendant was originally sentenced to state prison in case No. 8834 on May 2, 1990. He remained in custody until November 29, 1990, at which time a combined sentence was pronounced in both cases pursuant to section 669, section 1170.1, subdivision (a) and California Rules of Court, rule 452. Since defendant was subject to a prison commitment in case No. 8834 between May 2 and November 29, 1990, that in-custody time was attributable solely to case No. 8834 (see In re Rojas (1979) 23 Cal.3d 152, 155-156 [151 Cal. Rptr. 649, 588 P.2d 789]) and defendant was entitled to have that in-custody time credited against the consecutive eight-month sentence imposed for that case. Defendant would be further entitled to the credits authorized by section 4019 for said in-custody time.

DISPOSITION
The case is remanded to the trial court with directions to amend the judgment to award defendant presentence credits as required by the views expressed herein.
Martin, J., and Thaxter, J., concurred.
NOTES
[1]  All statutory references are to the Penal Code unless otherwise indicated.
