You have up to 6 months to apply for a Schengen visa before your trip. In the case of student visas, you must apply for your visa at least 90 days before the commencement of your program.