How is Expiry date of drugs determined?

Most medicines, which are chemical compounds and their combinations, degrade with time. This process is usually accelerated by heat and exposure to light. So the stability of every new formulation has to be checked over a period of time to evaluate its effective shelf-life. Ideally this should be done by storing the medicine at room temperature for some time. However, this method is time consuming. So what is done instead is that the medicine is stored at four different temperatures and under controlled conditions of light and humidity. The rates at which the medicine deteriorates are monitored. The compound’s stability at room temperature is calculated from the accelerated degradation tests made at higher temperatures. This allows scientists to fix a date beyond which the medicine may not be effective.