Appeal from a judgment of the County Court of Saratoga County (Scarano, Jr., J.), rendered September 26, 2002, convicting defendant upon his plea of guilty of the crime of criminal contempt in the first degree.
In July 2002, defendant was charged in a superior court information with criminal contempt in the first degree after he was involved in a physical altercation with his wife and violated an existing order of protection. He pleaded to this charge and, as part of the plea, executed a written waiver of his right to appeal. On September 26, 2002, defendant was sentenced, in accordance with the plea agreement, to a prison term of IV2 to 3 years. On that date, County Court also issued a permanent order of protection directing defendant not to have any contact with the victim, which order was to remain in effect until September 26, 2010.
Defendant’s sole contention on appeal is that County Court set an illegal expiration date for the order of protection and did not comply with the requirements of CPL 530.12 (5). Preliminarily, we note that insofar as defendant’s challenge goes to the legality of a portion of the sentence, it is not encompassed by his waiver of the right to appeal (see People v Seaberg, 74 NY2d 1, 9 [1989]; People v Espino, 279 AD2d 798, 799 [2001]; see e.g. People v Holmes, 294 AD2d 871, 872 [2002], lv denied 98 NY2d *795730 [2002]). Turning to the merits, CPL 530.12 (5) provides that the duration of an order of protection issued upon felony-conviction of a crime between spouses may not exceed the greater of “(i) five years from the date of such conviction, or (ii) three years from the date of the expiration of the maximum term of an indeterminate or the term of a determinate sentence of imprisonment actually imposed.” Here, the order of protection was set to expire eight years after the date of defendant’s conviction and five years after the date of the expiration of the maximum term of defendant’s sentence, well in excess of the statutory time period. The People concede that this was error. Therefore, the order of protection must be amended accordingly (see People v Holmes, 294 AD2d 871, 872 [2002], lv denied 98 NY2d 730 [2002]; see also People v Puno, 294 AD2d 875, 876 [2002], lv denied 98 NY2d 680 [2002]; People v Goodband, 291 AD2d 584, 586 [2002]; People v Sullivan, 284 AD2d 917, 919 [2001], lv denied 96 NY2d 942 [2001], 97 NY2d 658 [2001]).
Cardona, P.J., Crew III, Spain and Lahtinen, JJ., concur. Ordered that the judgment is modified, on the law, and matter remitted to the County Court of Saratoga County for resentencing limited solely to changing the expiration date of the order of protection, and, as so modified, affirmed.