As you can see from the chart how long drugs are detectable depends on which drugs you are looking for, and what kind of test you use Saliva (Spit) or Urine (Pee).
Marijuana is only detectable for a few hours in saliva, but is detectable for up to 30 days in urine.
Opiates like Heroin, Morphine, and Codeine are only detectable for short periods in saliva. but people with addictions to opiates generally need to take them multiple times per day to keep from withdrawal.
It's important to realise the detection times in the diagram are averages. Actual detection times vary from person to person.
It's also important to realise that there are legitimate reasons for people to take opiates, or amphetamines, and a positive test result doesn't mean the person tested is 'stoned' or impaired by the drug.
Cross reactions also occur with some prescription medicines.