How long does Previous Check Engine code stay in your car system?

recently my check engine light turned on and it went into limp mode. but the light turned off. can i check previous code and how long does it stay in the system. thanks
2 answers 2