In December 2007, defendant was alleged to have sold a quantity of cocaine to an undercover police officer during a buy/bust operation that was being conducted in the City of Schenectady, Schenectady County. Shortly after the sale took place, defendant was arrested and later charged by indictment with both criminal sale and criminal possession of a controlled substance in the third degree. Following a Mapp/Dunaway hearing, County Court (Drago, J.) concluded that probable cause existed for defendant’s arrest and, as a result, denied his motion to suppress the drugs found on his possession at the time of his arrest, as well as evidence that he was identified by the undercover police officer shortly after the sale had taken place. Subsequently, defendant pleaded guilty to attempted criminal sale of a controlled substance in the third degree and agreed, both orally and in writing, to waive his right to appeal in return for a commitment that he receive a prison sentence of four years, followed by three years of postrelease supervision. Defendant was sentenced accordingly and now appeals.
Defendant does not deny that, after conferring with counsel, he agreed to waive his right to appeal or that the waiver was knowingly and voluntarily entered. Instead, he argues that, as rendered, the waiver should not be interpreted to preclude a challenge to County Court’s decision denying his motion to suppress. In that regard, defendant argues that he “was advised only that he was waiving his right to appeal from his ‘plea.’ ” However, during the plea allocution, the court explained to defendant the consequences of waiving his right to appeal, and that explanation was reinforced by defendant’s written waiver that specifically stated that, among other things, he was waiving his right to appeal the court’s rulings made on the motion to suppress (see People v Schmidt, 57 AD3d 1104 [2008]; People v McMillan, 55 AD3d 1064, 1066 [2008], lv denied 11 NY3d 899 [2008]; People v Collins, 53 AD3d 932, 933 [2008], lv denied 11 NY3d 831 [2008]).
*1355Defendant also claims that County Court, in its sentence, erred by failing to give him credit pursuant to Penal Law § 70.30 (3) for the time he served in jail on an unrelated conviction. In that regard, in 1997, defendant was sentenced to two years in prison on a conviction for attempted criminal possession of a weapon in the third degree, which was subsequently vacated as the result of a CPL article 440 motion decided after defendant had completed serving this sentence and had been released from prison. Defendant then entered a guilty plea to a lesser charge to satisfy the charge pending against him in connection with that incident and received a one-year jail sentence, which was deemed satisfied by the time he had already served in prison prior to the conviction being vacated. Defendant now argues that, because he actually served two years in prison on that charge, County Court, in this matter, should have given him credit for the extra year he spent in prison and imposed a three-year sentence as opposed to the four years as stipulated by his plea bargain.
Penal Law § 70.30 (3) specifically provides that “[i]n any case where a person has been in custody due to a charge that culminated in a dismissal or an acquittal, the amount of time that would have been credited against a sentence for such charge, had one been imposed, shall be credited against any sentence that is based on a charge for which a warrant or commitment was lodged during the pendency of such custody ” ([emphasis added]; see People ex rel. Dunne v Jones, 77 AD2d 729 [1980]). The charge that resulted in defendant’s two-year sentence was not dismissed and defendant was not acquitted of committing that crime; rather, after the conviction was vacated, he entered a guilty plea to a lesser charge in full satisfaction of that charge and received a one-year sentence. Moreover, when arrested on this matter, defendant was not in prison and had completed serving his sentence on the prior charge. As such, Penal Law § 70.30 (3), by its terms, is clearly not applicable and defendant was not entitled to any credit in connection with the time in jail he served on his prior sentence (see generally People v Meredith, 172 AD2d 364, 364-365 [1991], lv denied 78 NY2d 1078 [1991]).
Finally, as to any suggestion by defendant that the sentence imposed was harsh and excessive because it did not take into account the additional year he served on the unrelated sentence, such an argument is foreclosed by his valid waiver of his right to appeal (see People v Walley, 63 AD3d 1284, 1286 [2009]; People v Dixon, 62 AD 3d 1214, 1215 [2009], lv denied 13 NY3d 743 [2009]).
*1356Cardona, EJ., Mercure, Spain and Malone Jr., concur. Ordered that the judgment is affirmed.