I know its important to have fuel in the tank but how long before a workout shoulkd I be eating ?
No one can answer that, you need to experiment for yourself. Some people can eat right before working out without any problems and some don't.
It also depends on what you eat before working out so if you have to train right after eating I'd advice not to eat anything too heavy and slow digesting like a steak and potatoes.