I don't know how to help you, but the least I can say is that you're not alone. At all.
Daydreaming became a problem to me when I realize I rather daydream than actually live my life.
The thing is, you feel invicible when you daydream. You can become whoever you'd want to be. I daydream a lot about '' what would have happened if... ''. I don't know if you ever think about such things, but I think a lot about mistakes I made. People I rejected that I should not. Things I made that I regret, things I didn't made that I regret not doing. I invent myself a new life, a better one.
You have to ''force'' yourself to focus, even if you're bored and sad. Even if you're feeling a bit depressed, even if you hate yourself and you want to cry. Take one day at the time. I personnaly started writing, it's a creative way to express what my daydreams we're expressing. It's a time where I let myself daydream, so I tend to do it less when i'm with other people.
It's easier to daydream than to go out and change, i'm still not here yet. You already figured out why you're doing it, which is a good start.