Patients with a longer diabetes duration (≥ 7 years) had significantly lower risks of TNBC and HER2-positive breast cancer but were more likely to have ER- and PR-positive subtypes and histological grade I tumors. Here, ERBB2 is linked to diabetes mellitus.