The past perfect continuous tense is used to talk about longer situations that continued up to the moment in the past we are talking about.
Past Perfect Continuous Timeline
"By the time I left England we had been living in Bristol for five years."
"Her back was sore because she had been sitting at the computer all day."
It is also used to say how long something went on for, up to a time in the past.
We apologised because we had kept them waiting for 3 hours.
We apologised because we had kept them waiting since lunchtime.
!Note It is always for a length of time and since a point in time.