- such long time
- such a long time
I know that (time) is an uncountable noun but I'm a bit confused because I heard many people saying such a long time so which of them is correct?
The noun "time" is usually uncountable, but it does have some countable senses, such as this one. In the sense of "a duration" you can say "a long time" or "write down the times of the runners".
Similarly you can say "We had a great time at the concert" and "He's fallen over three times". As you can see there are quite a few countable uses of the word time. It is still more common as a non-count noun, and is always uncountable in the physics sense of the progress of the past into the future.
So in your example, in context "I've been working for such a long time that I am falling asleep at my desk." would be the correct grammar.