Diabetes mellitus (DM) is a risk factor for pancreatic cancer but its prognostic impact remains controversial. We aimed to investigate the association between long-standing DM and the risk of mortality. This population-based cohort study analyzed data from the national healthcare database in Taiwan. We identified all patients diagnosed with pancreatic cancer and excluded those who were diagnosed with DM within 2 years of the cancer diagnosis. Eligible patients were grouped into long-standing DM (>2 years) and non-diabetic controls, and were compared for overall survival using a Cox proportional hazard model. Sensitivity tests stratified by cancer stages (as indicated by specific treatment) were performed. Patients with long-standing DM were significantly older (mean age, 71.38 vs. 66.0 years, P < 0.0001) and had a higher Charlson comorbidity index (9.53 vs. 6.78, P < 0.0001) and diabetes comorbidity severity index (2.38 vs. 0.82, P < 0.0001) compared with the non-DM controls. Although the unadjusted analysis showed a higher risk of mortality in the patients with long-term DM (crude hazard ratio [HR], 1.26; 95% confidence interval [CI], 1.20-1.33, P < 0.0001), the association became insignificant after adjustment for age, sex, and comorbidity index (adjusted HR, 1.01; 95% CI, 0.95-1.06, P = 0.84). Subgroup analyses also showed no association between long-term DM and mortality in various subgroups stratified by cancer treatment. After adjusting for associated comorbidities and complications, long-standing DM per se was not an independent prognostic factor for overall survival in this nationwide population-based cohort with pancreatic cancer.