At least 30 days before to the expiration of your current study permit, you should submit an application to extend it. On the other hand, we advise you to apply more than 30 days before it expires.