The past perfect continuous tense is a verb tense that shows that something started in the past and continued up until a point in the past. It is used to describe an ongoing or incomplete action that was happening before another action or event in the past. The past perfect continuous is formed using the past perfect of the auxiliary verb to be and the present participle of the main verb.

I had been studying for hours when I fell asleep. (The action of studying started in the past and continued up until the time when I fell asleep.)

She had been working on that project for weeks before she finished it. (The action of working on the project started in the past and continued up until the time when she finished it.)

Formation of Past Perfect Continuous

#1. The Past Perfect Continuous is formed by means of the Past Perfect of the auxiliary verb to be and Participle I of the notional verb.

#2. In the interrogative form, the first auxiliary verb is placed before the subject. And in the negative form, the negative particle not is placed after the first auxiliary verb.

Affirmative Interrogative Negative
I had been writing
He had been writing
She had been writing
We had been writing
You had been writing
They had been writing
Had I been writing?
Had he been writing?
Had she been writing?
Had we been writing?
Had you been writing?
Had they been writing?
I had not been writing
He had not been writing
She had not been writing
We had not been writing
You had not been writing
They had not been writing

#3. The contracted affirmative forms are:

Iโ€™d been writing
Sheโ€™d been writing

The contracted negative forms are:

I hadnโ€™t been writing
We hadnโ€™t been writing

#4. The negative-interrogative forms are:

Had he not been writing? = Hadnโ€™t he been writing?
Had you not been writing? = Hadnโ€™t you been writing?

Use of Past Perfect Continuous

We distinguish two uses of the Past Perfect Continuous: the Past Perfect Continuous Inclusive and the Past Perfect Continuous Exclusive.

#1. The Past Perfect Continuous Inclusive denotes an action which began before a definite moment in the past, continued up to that moment and was still going on at that moment. Either the starting point of the action is indicated or the whole period of duration. The preposition for is used to denote the whole period of Since is used to indicate the starting point of the action.

We could not go out because it had been raining since early morning.
We could not go out because it had been raining for two hours.
He had been entertaining at restaurants for thirty years and he knew how to assure the smooth passage of the meal. (Bennett)

As has been stated above, the Past Perfect Inclusive is used to express an action which began before a definite moment in the past, continued up to that moment and was still going on at that moment, with verbs not admitting of the Continuous form, in negative sentences and with certain non-terminative verbs.

With verbs not admitting of the Continuous form the Past Perfect Inclusive is the only tense possible.

In negative sentences the Past Perfect Continuous Inclusive can be used, but it is far less common than the Past Perfect Inclusive.

With certain non-terminative verbs both the Past Perfect Inclusive and the Past Perfect Continuous Inclusive are used.

He said he had worked for twenty years. (The fact is emphasized.)
He said he had been working for a long time without achieving final results. (The process is emphasized.)
I had been reading about an hour when he came.

#2. The Past Perfect Continuous Exclusive denotes an action which was no longer going on at a definite moment in the past, but which had been in progress not long before.

I sobbed a little still, but that was because I had been crying, not because I was crying then. (Dickens)

Past Perfect Continuous Inclusive and the Past Continuous

The Past Perfect Continuous Inclusive should not be confused with the Past Continuous. The Past Continuous is used to denote an action going on at a definite moment in the past, no previous duration is expressed. The Past Perfect Continuous Inclusive is used when the previous duration of the action is expressed.

And now it was raining, had been raining for days the miserable fall rains of Eastern France. (Heym)
The magnificent motor-car was waiting at the kerb. It had been waiting for two hours. (Bennett)