
49 Cal.Rptr.3d 211 (2006)
142 Cal.App.4th 914
The PEOPLE, Plaintiff and Respondent,
v.
Pascal G. RAVAUX, Defendant and Appellant.
No. D047496.
Court of Appeal of California, Fourth District, Division One.
August 16, 2006.
*212 Bill Lockyer, Atty. Gen., David P. Druliner, Chief Asst. Atty. Gen., Gary W. Schons, Asst. Atty. Gen., Raymond M. DiGuiseppe, Deputy Atty. Gen., San Diego, CA, for Plaintiff and Respondent.
Susan E. Cardine, under appointment by the Court of Appeal, Indio, CA, for Defendant and Appellant.
McINTYRE, J.
Pascal G. Ravaux pleaded guilty to possession of methamphetamine with intent to sell, with enhancements for two prior convictions for possession and one prison prior for failing to remain unincarcerated for five years after release from prison. He contends that the trial court abused its discretion in denying his motion to withdraw his guilty plea and that he is entitled to one additional day of custody credit for time spent in police custody prior to his official booking. We conclude that the trial court acted within its discretion when it denied Ravaux's motion and correctly determined the custody credits to be given. We affirm the judgment of the lower court.

BACKGROUND
On December 2, 2004 San Diego police conducted surveillance on Ravaux's residence based on a complaint regarding narcotics activities in the garage. Andrew Briers entered the garage, and then left the house about 45 minutes later. While fleeing from the police, Briers threw a bag containing 250.90 grams of methamphetamine out the window of his car. The police recovered the bag and returned to Ravaux's house where they found 4.18 grams of methamphetamine in Ravaux's pocket and 185.5 grams in a bag in the garage. Ravaux was arrested sometime after 9:30 p.m. on December 2 and was booked into the San Diego County jail at approximately 12:28 a.m. on December 3.
Ravaux was initially charged with possession of methamphetamine with intent to sell. The information also alleged five prior convictions on similar charges and two prison priors. In exchange for a guilty plea to the underlying offense and admission of two of the prior convictions and one prison prior, the district attorney dismissed the remaining allegations against Ravaux. Before sentencing, Ravaux requested a continuance and moved to withdraw his plea, stating that he had not been adequately counseled by his attorney prior to the plea and that at the time of the plea he was suffering from medical problems that resulted in the plea not being given of his own free will. The trial court denied *213 the motion and sentenced Ravaux to ten years in prison. Ravaux was awarded 321 custody credits based on the date of his booking.

DISCUSSION

I. Motion to Withdraw Guilty Plea

A defendant may move the trial court to set aside a guilty plea for good cause at any time before the entry of judgment. (Pen.Code, § 1018; all further statutory references are to the Penal Code.) "Good cause" means mistake, ignorance, fraud, duress or any other factor that overcomes the exercise of free judgment and must be shown by clear and convincing evidence. (People v. Cruz (1974) 12 Cal.3d 562, 566, 116 Cal.Rptr. 242, 526 P.2d 250.) The grant or denial of such a withdrawal motion is "within the sound discretion of the trial court and must be upheld unless an abuse thereof is clearly demonstrated." (People v. Superior Court (Giron) (1974) 11 Cal.3d 793, 796, 114 Cal.Rptr. 596, 523 P.2d 636.) We are required to accept all factual findings of the trial court that are supported by substantial evidence. (People v. Fairbank (1997) 16 Cal.4th 1223, 1254, 69 Cal. Rptr.2d 784, 947 P.2d 1321.) Here, there is substantial evidence to support the trial court's determination that Ravaux's plea was knowingly and intelligently entered of his own free will, unhindered by any medical condition and with adequate representation.
Ravaux indicated numerous times that he understood the consequences of the guilty plea and the rights he was waiving. He completed the plea form, attesting that he understood and accepted fully the plea agreement and the rights he was required to waive in order to accept the deal. Ravaux also attested on this form that he was sober and that his judgment was not impaired, and that he "had not consumed any drug, alcohol or narcotic within the past 24 hours." While entering his plea in front of the court, Ravaux was again apprised of his rights, informed of the consequences of a guilty plea, and advised by counsel. He acknowledged and answered affirmatively to each of the court's explanations before entering his plea. The only indication Ravaux was confused in any way, when he initially denied having any intent to sell the methamphetamine, was addressed by the court and counsel. This is inconsequential considering that no where else in the record is there any indication that Ravaux was impaired, confused or less than completely lucid.
Ravaux's medical condition was only brought up by counsel at the end of the hearing, and the court noted that he should continue to be monitored. At no time did his medical condition or demeanor indicate to his attorney or the court that he was intoxicated or confused to the point where his judgment was impaired. The sole evidence that his judgment was affected by medication is Ravaux's own assertions in support of his motion to withdraw the plea. These assertions were contrary to the position he took under oath at the time the guilty plea was given. They were also at odds with what the trial judge, who presided over both hearings, recalled about the demeanor and performance of Ravaux at the plea hearing. It is entirely within the trial court's discretion to consider its own observations of the defendant in ruling on such a motion. (People v. Fairbank, supra, 16 Cal.4th at p. 1254, 69 Cal.Rptr.2d 784, 947 P.2d 1321.) The court may also take into account the defendant's credibility and his interest in the outcome of the proceedings. (Ibid.; People v. Hunt (1985) 174 Cal.App.3d 95, 103, 219 Cal.Rptr. 731.) Here the trial court found, based on its own recollection of the previous hearing and the lack of credible *214 evidence to the contrary, that Ravaux was not impaired to the point that his independent judgment was overcome at the time he entered the guilty plea. This determination was supported by substantial evidence.
Ravaux also contends that he should be allowed to withdraw his plea because he did not receive adequate legal advice before entering it. However, Ravaux was allowed to consult with counsel prior to, and was represented by counsel at, the hearing when he entered the plea and assented to its terms. Prior to being represented by the public defender's office when the plea was entered, he was represented by a different attorney at his arraignment, several readiness conferences, the preliminary hearing, and the entering of the initial plea of not guilty. He retained different representation yet again before the change of plea hearing. Ravaux was represented by legal counsel during the entire process. The fact that he may have been persuaded, or was reluctant, to accept the plea is not sufficient to warrant the plea being withdrawn. (People v. Urfer (1979) 94 Cal.App.3d 887, 892, 156 Cal. Rptr. 682.) "Guilty pleas resulting from a bargain should not be set aside lightly and finality of proceedings should be encouraged." (People v. Hunt, supra, 174 Cal. App.3d at p. 103, 219 Cal.Rptr. 731.) The trial court was acting completely within its discretion when it determined that Ravaux had been adequately represented and denied his motion to withdraw the plea.
Ravaux argues that comments made by the trial court upon being informed of his intention to make a motion to withdraw his guilty plea demonstrate bias against him. These comments are ambiguous at best. They appear to be an expression of frustration rather than bias on the part of the trial court resulting from Ravaux's request for a continuance almost two months after the guilty plea was entered. Because the trial court's ruling was supported by substantial evidence and not an abuse of discretion, the trial court's comments do not persuade us to overturn the judgment below.

II. Custody Credits

Anyone convicted of a felony is entitled to credit against his term of imprisonment for time spent in custody prior to sentencing. (§ 2900.5, subd. (a).) Whether a defendant is in "custody" for the purposes of section 2900.5 while detained by the police prior to being booked into jail is a matter of statutory interpretation, a question of law we review de novo. (Waterman Convalescent Hospital, Inc. v. State Dept. of Health Services (2002) 101 Cal.App.4th 1433, 1437, 125 Cal.Rptr.2d 168.) We conclude that a defendant is not in custody within the meaning of section 2900.5 prior to being processed into a jail or similar custodial situation as described in section 2900.5, subdivision (a). The trial court was correct in calculating Ravaux's custody credits beginning when he was booked into jail rather than from the time of his arrest.
The plain language of section 2900.5 addresses only residential custody arrangements and makes no mention of detention, seizure or arrest by the police as being the type of custody included in the calculation of custody credits. Time spent prior to sentencing in "jail, camp, work furlough facility, halfway house, rehabilitation facility, hospital, prison, juvenile detention facility, or similar residential institution" is to be credited against any sentence imposed after conviction. (§ 2900.5, subd. (a), italics added.) Arrest or detention by police prior to booking is not mentioned anywhere in section 2900.5. It is clear from the plain language of the statute that custody credits are to be given for time spent *215 within a residential detention facility, not for merely being in the custody of police.
That the Legislature considered only residential custody situations and not arrest and detention by the police as the concern of this statute is also apparent in the language directing the trial court to determine the credit a defendant is entitled to: "It shall be the duty of the court imposing the sentence to determine the date or dates of any admission to, and release from, custody prior to sentencing[.]" (§ 2900.5, subd. (d), italics added.) Had the Legislature intended to begin the counting of custody credits at the time of detention, it could have done so by using "arrest" or "seizure" in place of "admission." Rather, the Legislature's use of "admission" clearly implies the placing of the defendant in a facility, not merely detention by police.
Ravaux's interpretation of the statute, granting custody credit beginning at the time of arrest, does not further the purposes for which section 2900.5 was adopted. The statute addresses a "dual legislative purpose of `eliminat[ing] the unequal treatment suffered by indigent defendants who, because of their inability to post bail, served a longer overall confinement than their wealthier counterparts' [citation] and equalizing the actual time served in custody for given offenses. [Citation.]" (People v. Pottorff (1996) 47 Cal. App.4th 1709, 1715, 55 Cal.Rptr.2d 536, quoting In re Atiles (1983) 33 Cal.3d 805, 812, 191 Cal.Rptr. 452, 662 P.2d 910.) This "reflect[s] the basic philosophy that when a person is incarcerated he is being punished by the reality of incarceration." (In re Watson (1977) 19 Cal.3d 646, 651, 139 Cal.Rptr. 609, 566 P.2d 243.) Being arrested and detained by the police, though certainly onerous, is not incarceration until the subject has been booked into jail. There is none of the unequal treatment this statute was directed at during a period of prebooking detention because all felony defendants, whether they are able to post bail or not, are likely to be arrested and detained by police prior to being booked into jail. Extending the scope of the statute to the limits argued by Ravaux does nothing to eliminate the unequal treatment the statute was designed to avoid.
Ravaux argues that the definition of "custody" adopted by the U.S. Supreme Court in the context of Miranda should be applied to section 2900.5. (Miranda v. Arizona (1966) 384 U.S. 436, 86 S.Ct. 1602, 16 L.Ed.2d 694 (Miranda).) In that context an individual is in custody for the purposes of determining whether he has a right to counsel and must be informed of his right to remain silent, if a reasonable person in the same situation would believe they are not free to leave. (Stansbury v. California (1994) 511 U.S. 318, 324, 114 S.Ct. 1526, 128 L.Ed.2d 293.) This definition of custody, as discussed above, is not compatible with the language or the purpose of the statute. The custodial interrogation situations Miranda was meant to address are radically different than the type of residential custody that is the subject of section 2900.5. In Miranda custody was defined so that suspects who are detained by police for questioning would be advised of their rights. Section 2900.5 defines custody so that those who are incarcerated receive credit for the time they serve. Applying the Miranda standard in this context does not further the policy advanced in either. There is no authority applying this standard to custody credit determinations.
It should also be noted that Ravaux's argument would lead to absurd results and create further ambiguity in applying section 2900.5. Under such a definition of custody, a defendant would be eligible for *216 a day of custody credit on occasions when he was detained by the police and questioned, but released without being booked into jail. In the course of an ongoing criminal investigation a defendant may be contacted and questioned by police several times, each time potentially putting the defendant in custody under the Miranda standard. Because defendants are given credit based on the number of days in custody rather than the number of 24-hour periods, a full day would be credited regardless of the actual length of the detention. (§ 2900.5, subd. (a).) Further ambiguity would be created by virtue of the court having to review in detail the circumstances surrounding the detention of a defendant, possibly on more than one occasion and for varying reasons, in order to determine at what time or times he was placed into custody and whether that custody was related to the offense for which he was convicted. By contrast, the booking of a suspect into jail represents a bright line for trial courts to begin counting credits.
Ravaux contends that section 2900.5 violates the principles of equal protection because suspects booked into rural jails may be processed more quickly than those being booked into large urban jails. This asserted difference in booking time is not supported by any evidence in the record. To establish a violation of equal protection it must be shown that the statute has created a classification that affects two or more similarly situated groups unequally. (People v. Guzman (2005) 35 Cal.4th 577, 584, 25 Cal.Rptr.3d 761, 107 P.3d 860.) Here, no such classification has been shown.
The trial judge awarded the correct number of custody credits by beginning the calculation under section 2900.5 at the time Ravaux was booked into jail.

DISPOSITION
The judgment is affirmed.
HALLER, Acting P.J., and McDONALD, J., concur.
