*525Appeal from a judgment of the County Court of Schenectady County (Hoye, J.), rendered October 15, 2002, convicting defendant upon his plea of guilty of the crime of attempted criminal sale of a controlled substance in the third degree.
Defendant waived his right to appeal and pleaded guilty to the reduced charge of attempted criminal sale of a controlled substance in the third degree. During the plea colloquy, as well as at sentencing, defendant indicated that he recalled being adjudicated a youthful offender on the conviction cited in the prior felony offender information filed against him. No information regarding youthful offender treatment was contained in the documentation obtained by the People. Although County Court informed defendant that he was entitled to a hearing on the matter (see CPL 400.21), defendant indicated his desire to proceed with sentencing and admitted the prior felony conviction. Defendant thereafter was sentenced in accordance with the plea agreement to a prison term of 3 to 6 years.
On appeal, defendant contends that he was improperly sentenced as a second felony offender when County Court failed to conduct a hearing pursuant to CPL 400.21. Initially, we note that defendant’s waiver of the right to appeal does not preclude his challenge to the legality of the sentence (see People v Dukes, 14 AD3d 732, 733 [2005], lv denied 4 NY3d 885 [2005]). Nevertheless, we find defendant’s contention to be without merit. The record clearly establishes that defendant knowingly waived his right to a predicate felony hearing and then admitted to the prior felony (see People v Jones, 185 AD2d 470, 472 [1992], lv denied 80 NY2d 975 [1992]; People v Williams, 106 AD2d 786, 787 [1984]).
Cardona, P.J., Crew III, Peters, Carpinello and Kane, JJ., concur. Ordered that the judgment is affirmed.