According to the Law on Foreigners a long-term EU resident permit is granted to foreigner who stayed in Poland legally and uninterruptedly for at least five years before applying.
 
The period of residence in Poland includes half of the period of foreigner&rsquos stay on the basis of study visa, or temporary residence permit granted for the start or continue of stationary higher education studies or doctoral studies.
 
However, the period of residence in Poland does not include the residence on the basis of residence permit obtained for the purpose of family reunification.
 
Stay in Poland is considered to be uninterrupted if none of interruptions was longer than 6 month and it does not exceed in total 10 months within the period mentioned in the Law on Foreigners. Except if interruption was caused by:
- execution of  job duties or work outside Polish Republic on the basis the of concluded agreement with employer, whose office is located  in Poland
- accompanying a spouse who execute job duties or work in circumstances mentioned in the p.1
- foreigner's medical treatment.
 
According to art. 65 of Law on Foreigners, the foreigner will get refusal for long-term EU-resident permit because of circumstances mentioned in p.1, 2 of the Law. There is no liberty in making such decisions, as in making decisions which concern other cases.
 
Your trips to Czech Republic during doctoral studies can&rsquot be considered as circumstances that can justify your too long stay abroad Poland. Stay abroad Poland during the analyzed period does not constitute either execution of professional duties or work under a contract with the employer.
 
To my mind your situation is not typical. The law does not provide a direct answer to the question how the authority should calculate your period of residence in Poland. As I said The Law refers to paragraph about granting the settlement permit. The process of getting settlement permit in Poland significantly differ in the method of calculating the period of stay because regulation does not contain any exclusions in the calculation of the period of stay.
 
To my mind in this particular case the Mazovian Governor should investigate evidences of uninterrupted residence during the last 5 years and find out how it was counted taking into account exception prescribed by law for your particular case.
 
id not explain on what basis they counted your trips abroad during your being in Poland on the basis of a residence permit for the purpose of connecting with family. They also don&rsquot explain why they summed up trips abroad during your being in Poland on the basis of doctoral studies.
 
In the conclusion, I see a chance of winning this case, however, please be aware that your situation is precedential in its own way and it is possible that you will need to resolve this issue by the Regional Administrative Court.
 
Comments to the post