Objective To investigate the prevalence of cognitive frailty in elderly female inpatients with type 2 diabetes mellitus (T2DM), and to analyze its influencing factors. Methods A total of 125 elderly female inpatients with T2DM treated in the Department of Endocrinology, Ruikang Hospital Affiliated to Guangxi University of Chinese Medicine, from March to October 2021, were enrolled as research subjects. The self-designed general information questionnaire; the Survey of Health, Ageing and Retirement in Europe Frailty Instrument (SHARE-FI); Montreal Cognitive Assessment (MoCA); Mini Nutritional Assessment-Short Form (MNA-SF); Instrumental Activities of Daily Living Scale (IADLs); Social Support Rating Scale (SSRS); and Geriatric Depression Scale, 5-item version (GDS-5) were used for investigation. Cognitive frailty was assessed according to SHARE-FI and MoCA scores. Univariate analysis and a multivariate logistic regression model were used to analyze the influencing factors of cognitive frailty in elderly female inpatients with T2DM. Results A total of 125 questionnaires were distributed, and 118 valid questionnaires were collected, with a valid response rate of 94.40%. Among the 118 elderly female inpatients with T2DM, 51 (43.22%) had cognitive frailty. Univariate analysis showed statistically significant differences in age, marital status, number of children, regular exercise, sleep duration, number of medications, number of comorbidities, presence of other cardiovascular diseases, presence of respiratory diseases, depression status, nutritional status, and instrumental activities of daily living between patients with and without cognitive frailty (all P<0.05). Multivariate logistic regression analysis showed that advanced age (>70 years), prolonged sleep duration (>9 h), and at risk of malnutrition were independent risk factors for cognitive frailty in this population (all P<0.05). Conclusion The prevalence of cognitive frailty is relatively high in elderly female inpatients with T2DM, and advanced age, prolonged sleep duration, and at risk of malnutrition are independent risk factors of cognitive frailty in this population. Healthcare professionals should prioritize the screening and intervention of cognitive frailty in this population, implementing comprehensive management strategies targeting these aforementioned risk factors to delay disease progression and enhance patients' quality of life.