My understanding is that hair follicle testing can detect drug use up to a year, certainly for 6 months. That's why it's the gold standard for testing. The trace is in the root of your hair so if you take drastic measures don't forget arms, legs, pubics, toes (ha-ha, in my case it would be the ears).
Anybody facing this test is usually faced with serious life consequences, i.e, loss of job, children or freedom. Get thee to an attorney. I'm old enough to have had plenty of trouble and wise enough to get through most of it. I've given this advice before; pay for your own test. If it comes up positive then your only hope is to 'fess up'. Acknowledge your weakness, apologize for your indiscretions, agree to any conditions. Sincerity will take you a lot further than deceit. Sorry for the long post.
I wish you the best.