Drugs are different so is the time it takes for each medication to be cleared from your system. The amount of time it take a drug to leave your body depends on the half life of the drug. Half life refers to the time it takes your liver or kidney to breakdown or excrete half of a medication from your body.
For example, if you take 50mg of a medications and the medication has a half life of 2 hours, it means in 2 hours only half (25mg) of this medication will remain in your body. In another 2 hours it would reduce to half (12.5mg) of what it was 2 hours ago. It continues this way until nothing is left in your system.