A drug's length of effect in the human body is determined by its pharmacokinetics.
You have to take note of the absorption, which is the process where the substance enters the circulation. Some drugs are absorbed quickly, like those taken via I.V route.
Distribution is the dispersion of substances throughout the tissues and fluids in the body. Drugs stored in fatty tissue stay longer inside the body because you have to burn some of those fats to release the medication into the system.
After a drug is metabolized, the patient's kidney or liver status may affect how long a drug stays inside the body. Damage to these organs can cause substances to circulate longer inside the body and produce harmful effects. This is also true with the last part of pharmacokinetics, which is Excretion, where the liver and the kidneys play their own parts in getting the drug out of the body.