Aim: To assess whether the beta‐cell function of inpatients undergoing antidiabetic treatment influences achieving time in range (TIR) and time above range (TAR) targets. Materials and Methods: This cross‐sectional study included 180 inpatients with type 2 diabetes. TIR and TAR were assessed by a continuous glucose monitoring system, with target achievement defined as TIR more than 70% and TAR less than 25%. Beta‐cell function was assessed by the insulin secretion‐sensitivity index‐2 (ISSI2). Results: Following antidiabetic treatment, logistic regression analysis showed that lower ISSI2 was associated with a decreased number of inpatients achieving TIR (OR = 3.10, 95% CI: 1.19‐8.06) and TAR (OR = 3.40, 95% CI: 1.35‐8.55) targets after adjusting for potential confounders. Similar associations still existed in those participants treated with insulin secretagogues (TIR: OR = 2.91, 95% CI: 0.90‐9.36, P =.07; TAR, OR = 3.14, 95% CI: 1.01‐9.80) or adequate insulin therapy (TIR: OR = 2.84, 95% CI: 0.91‐8.81, P =.07; TAR, OR = 3.24, 95% CI: 1.08‐9.67). Furthermore, receiver operating characteristic curves showed that the diagnostic value of the ISSI2 for achieving TIR and TAR targets was 0.73 (95% CI: 0.66‐0.80) and 0.71 (95% CI: 0.63‐0.79), respectively. Conclusions: Beta‐cell function was associated with achieving TIR and TAR targets. Stimulating insulin secretion or exogenous insulin treatment could not overcome the disadvantage of lower beta‐cell function on glycaemic control. [ABSTRACT FROM AUTHOR]