ObjectiveWe aim to investigate the prevalence, trends, and major risk factors of type 2 diabetes mellitus (T2DM) among adult psychiatric inpatients in Beijing, China.Research design and methodsWe did a longitudinal observational study using data from the Beijing Municipal Commission of Health and Family Planning Information Center, including 157 570 adult psychiatric inpatients in 19 specialized psychiatric hospitals from 2005 to 2018 in Beijing. Data on demographic characteristics and antipsychotic medication use were obtained from electronic health records. Schizophrenia, T2DM, and comorbidities were defined according to the International Classification of Diseases, 10th revision codes of discharge diagnosis. The overall prevalence of T2DM in adult psychiatric inpatients was calculated, and the annual prevalence of T2DM was calculated and adjusted to the overall participant population. Univariate and multivariate logistic regression analyses were performed to obtain crude ORs and adjusted ORs (aORs) on the risk of T2DM in patients with different demographic characteristics, schizophrenia, antipsychotic medication use, and different comorbidities. Age-specific prevalence of T2DM under a stratification of schizophrenia or other psychiatric disorders was calculated in the subgroup analysis.ResultsOut of 157 570 adult inpatients, 16 939 had T2DM, with a prevalence of 10.75% (95% CI 10.60% to 10.90%). The prevalence was 11.63% (95% CI 11.37% to 11.88%) among patients with schizophrenia and 10.17% (95% CI 9.98% to 10.37%) among patients with other psychiatric disorders. During 2005–2018, the prevalence of T2DM in adult patients increased over the years, from an adjusted prevalence of 5.20% in 2005, to 10.98% in 2010, 12.50% in 2015, and 12.71% in 2018. Results from the multivariate analysis showed that increasing age, diagnosis of schizophrenia (aOR=1.23, 95% CI 1.18 to 1.29), and comorbidities of hypertension (aOR=3.09, 95% CI 2.97 to 3.22), lipid disorders (aOR=1.95, 95% CI 1.88 to 2.04), and fatty liver (aOR=1.93, 95% CI 1.84 to 2.03) were major risk factors of T2DM in adult psychiatric inpatients.ConclusionsThe prevalence of T2DM was high among adult psychiatric inpatients in Beijing, China. Elderly patients, those with schizophrenia, and those with hypertension, lipid disorders, and fatty liver had higher prevalence of T2DM. Prevention and treatment of T2DM are of utmost relevance in hospitalized psychiatric patients.