You can apply up to six months before your card is expired
http://www.cic.gc.ca/english/helpcentre/answer.asp?qnum=065&top=10
As scylla said, at the day you apply for card renewal, go back 5 years, and make sure you have the required number of days. If you don't, not only would they refuse to renew your card, they would initiate revocation of your status as well.