Your residence period is reckoned from the date you were granted legal residence in Norway. This can be the date when you came to Norway or the date when you applied for a registration certificate or residence card.
If you have stayed in Norway with right of residence without having registered, you must substantiate how long you have been here with right of residence and that you have had right of residence here throughout this period.
If you have stayed abroad for two months or less during one calendar year, that will have no bearing on the calculation of your residence period. This means that such stays abroad are regarded as residence in Norway, and the time you have spent abroad will not be deducted. If you stay abroad for more than two months during a calendar year, however, the whole period abroad will be deducted, not just the part that exceeds two months. This is also the case if you were working abroad.