The past perfect continuous is formed using had + been + present participle. Questions are indicated by inverting the subject and had. Negatives are made with not
Statement: You had been waiting there for more than two hours when she finally arrived.
Question: Had you been waiting there for more than two hours when she finally arrived?
Negative: You had not been waiting there for more than two hours when she finally arrived.
We use the past perfect continuous to show that something started in the past and continued up until another time in the past. "For five minutes" and "for two weeks" are both durations which can be used with the past perfect continuous. Notice that this is related to the present perfect continuous; however, the duration does not continue until now, it stops before something else in the past.
Examples:
They had been talking for over an hour before Tony arrived.
She had been working at that company for three years when it went out of business.
How long had you been waiting to get on the bus?
Mike wanted to sit down because he had been standing all day at work.
James had been teaching at the university for more than a year before he left for Asia.
A: How long had you been studying Turkish before you moved to Ankara?
B: I had not been studying Turkish very long.