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 with-in 2 years of the cancer diagnosis. Eligible patients were grouped into long-standing DM (>2 years) and nondiabetic 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 years versus 66.0 years; P<.0001) and had a higher Charlson comorbidity index (9.53 versus 6.78; P<.0001) and diabetes comorbidity severity index (2.38 versus 0.82; P<.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 to 1.33; P<.0001), the association became insignificant after adjustment for age, sex, and comorbidity index (adjusted HR, 1.01; 95% CI, 0.95 to 1.06, P = .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. CCI = Charlson Comorbidity Index; CI = confidence interval; DCSI = Diabetes Complication Severity Index; DM = diabetes mellitus; HR = hazard ratio; ICD = International Classification of Diseases; NHIRD = National Health Insurance Research Database; RCIPD = Registry for Catastrophic Illness Patient Database.