Whenever the commissioner shall determine that any monies received under the provisions of this article were paid in error, he may cause the same to be refunded or credited, with interest, in accordance with such rules and regulations as he may prescribe, except that no interest shall be allowed or paid if the amount thereof would be less than one dollar. Such interest shall be at the overpayment rate set by the commissioner pursuant to subdivision twenty-sixth of section one hundred seventy-one of this chapter, or if no rate is set, at the rate of six percent per annum, from the date when the tax, penalty or interest to be refunded or credited was paid to a date preceding the date of the refund check by not more than thirty days. Provided, however, that for the purposes of this section, any tax paid before the last day prescribed for its payment shall be deemed to have been paid on such last day. Such moneys received under the provisions of this article which the commissioner shall determine were paid in error, may be refunded or credited out of funds in the custody of the comptroller to the credit of such taxes provided an application therefor is filed with the commissioner within four years from the time the erroneous payment was made, except if an agreement under the provisions of section five hundred ten (extending the period for determination of tax imposed by this article) is made within the four-year period for the filing of an application for refund provided for in this section, the period for filing an application for refund shall not expire prior to six months after the expiration of the period within which a determination may be made pursuant to the agreement or any extension thereof.
N.Y. Tax Law § 513