I have a clogged sweat gland on my foot. It is so painful to walk on sometimes. What can I do to get rid of and how long does it take to get rid of.

Sweat gland. How do you know it is a clogged sweat gland ? You need to see you podiatrist and get a diagnosis and then they will help you treat it appropriately . Good luck.
Clogged sweat gland. A clogged gland on the bottom of the foot is like a stubborn painful callus. Use vicks vapor rub to weaken the callus around the clogged gland, then par it down. Then use spray deodorant (the armpit kind) to decrease sweat, this decreases friction. If that doesn't help, try otc inserts from a drug store to help off-load callus area. Lastly, see a doctor to par it down. Hope that helps!
Need diagnosis. A clogged sweat gland? Those are not painful unless they are infected, which seems unlikely since you say it only hurts "sometimes". I strongly suggest that you see a dermatologist and get a precise diagnosis. Once you know what it is, it can be treated.