Patients hospitalized with heart failure (HF) and diabetes mellitus (DM) are at risk for worsening clinical status. Little is known about the frequency of therapeutic changes during hospitalization. We characterized the use of medical therapies before, during and after hospitalization in patients with HF and DM. We identified Medicare beneficiaries in Get With The Guidelines-Heart Failure (GWTG-HF) hospitalized between July 2014 and September 2019 with Part D prescription coverage. We evaluated trends in the use of 7 classes of antihyperglycemic therapies (metformin, sulfonylureas, GLP-1RA, SGLT2-inhibitors, DPP-4 inhibitors, thiazolidinediones, and insulins) and 4 classes of HF therapies (evidence-based β-blockers, ACEi or ARB, MRA, and ARNI). Medication fills were assessed at 6 and 3 months before hospitalization, at hospital discharge and at 3 months post-discharge. Among 35,165 Medicare beneficiaries, the median age was 77 years, 54% were women, and 76% were white; 11,660 (33%) had HFrEF (LVEF ≤ 40%), 3700 (11%) had HFmrEF (LVEF 41%-49%), and 19,805 (56%) had HFpEF (LVEF ≥ 50%). Overall, insulin was the most commonly prescribed antihyperglycemic after HF hospitalization (n = 12,919, 37%), followed by metformin (n = 7460, 21%) and sulfonylureas (n = 7030, 20%). GLP-1RA (n = 700, 2.0%) and SGLT2i (n = 287, 1.0%) use was low and did not improve over time. In patients with HFrEF, evidence-based beta-blocker, RASi, MRA, and ARNI fills during the 6 months preceding HF hospitalization were 63%, 62%, 19%, and 4%, respectively. Fills initially declined prior to hospitalization, but then rose from 3 months before hospitalization to discharge (beta-blocker: 56%-82%; RASi: 51%-57%, MRA: 15%-28%, ARNI: 3%-6%, triple therapy: 8%-20%; P < 0.01 for all). Prescription rates 3 months after hospitalization were similar to those at hospital discharge. In-hospital optimization of medical therapy in patients with HF and DM is common in participating hospitals of a large US quality improvement registry.