No, not the correct forum, but anyway...
Urine tests are conducted to detect the products that your body produces when various drugs are taken into the body. Different screens are performed for different drugs. There are "quick" tests, involving a test strip. The definitive "proof" is by gas chromatography (used to confirm, since instant tests have a % of false positives, and false negatives) Alcohol use can be determined from a sample of the blood or breath. Alcohol in the blood is gradually broken down by the body. A very small portion is released into the lungs, and can be detected and measured in exhaled breath.
How long AFTER a taking a drug or alcohol will the test still show it? Varies. Depends on the drug, and the test.
And FWIW, there is another test series called RIAH, that uses a hair sample- and will detect any drug use in past 6 months. You can ask Marion Barry how well that works. Sent him to Federal prison.
Bottom line- if you are on probation or parole, you better stay squeaky clean IF you like being a free man. If you want a chance to become Bubba's wife, go ahead and have that doobie.