It takes about two weeks, but i heard somewere that it can stay in your hair for up too six months... i dont know if thats true though.
Actually it is testable for 10-14 days after last contact. This time frame could be shorter or longer depending on your diet, as well as alcohol consumption, and your level of daily activity. **HINT** Excersize, and a healthy diet including citric acids and fruits and vegitables will shorten the amount of time needed.
I TOOK CLASSES IN COLLEGE AND THE TEXT BOOK SAYS ABOUT 30 DAYS!