Introduction This study aimed to investigate how depression and diabetes history, both short-term and long-term, before the diagnosis of pancreatic cancer are associated with cancer risk and survival outcomes. Methods Data from a linked registered-based 11% random sample of the population residing in Finland are used. The study cohort consists of 371,068 individuals aged 35 years old at the end of 1988. During 1999–2012, in total of 1196 individuals were diagnosed with primary pancreatic cancer. For each case, five cancer-free individuals were randomly selected from the study cohort matching with the case on year of birth, sex, and year of diagnosis. Mortality of cases was followed until the end of 2014. The history of antidepressant medication and anti-diabetic medication purchases were extracted up to 48 months (0–24 and 24–48 months separately) before the pancreatic cancer diagnosis. The effects of depression and diabetes associated with pancreatic cancer risk were evaluated using conditional logistic regression model, adjusting for age, sex, education level and marital status. Cox proportional hazards models were used to examine the effects of depression and diabetes history in relation to pancreatic cancer survival, controlling for age, sex, education level, marital status, year of diagnosis, cancer stage, and cancer subtypes. Results This study included 1196 cases with primary pancreatic cancer and 5980 cancer-free controls in total. The median age of cases at diagnosis was 70.0 and 75.9 years old for men and women, and the median follow-up time was 2.90 and 3.11 months respectively. One hundred and twenty-four percent and 90% higher risk of pancreatic cancer was found to be associated with anti-diabetic medication purchases 0–24 months (odds ratio [OR] = 2.24, 95% confidence interval [CI] = 1.90–2.64, P Conclusions Our findings confirmed that diabetes is strongly associated with pancreatic cancer risk. A strong association between anti-diabetic medication purchases 24–48 months before the pancreatic cancer diagnosis and the heightened pancreatic cancer risk was observed, but not for the cancer survival. History of antidepressant medication purchases before the cancer diagnosis were not associated with higher pancreatic cancer risk but worse survival. Further investigations are needed to evaluate these associations for different depression levels and types of diabetes.