Background Clostridioides difficile infection (CDI) is a disease that is potentially preventable by vaccination. A good knowledge of its epidemiology, which can change over time, is warranted for prevention purposes and to help decision-making on the use of vaccines in public health programs. The objective of the research was to determine the epidemiology of healthcare-associated CDI (HA-CDI) and community-associated CDI (CA-CDI) in hospitalized patients in Spain using point prevalence data. Methods Point prevalence survey data on infections of hospitalized patients for years 2012–2019 were analyzed. HA-CDI and CA-CDI prevalence rates were calculated. Both HA-CDI and CA-CDI, as well as age group prevalence rates, were examined for trends. Patient comorbidities were tested for association to CDI. Results The prevalence of CDI in Spanish hospitals has grown exponentially from 14.1% in 2012 to 35.9% in 2019 (cases/10.000 hospitalized patients). Almost two thirds of the cases are of nosocomial onset. This increase was observed for HA-CDI and CA-CDI at an annual rate of 1.11% (CI 95% 1.08–1.15) and 1.09% (CI 95% 1.04–1.13), respectively. Patients 50 years old or older represent 87% of the total number of cases. Patients suffering from neoplasm (OR 1.39), immunodeficiency (OR 3.26), neutropenia (OR 3.70), cirrhosis (OR 1.92) and chronic renal failure (OR 1.91) have a significant increased risk of developing CDI, after adjusting for age. Conclusion In Spain, the prevalence rate of both HA-CDI and CA-CDI have been increasing. Burden of CDI as well as clinical and epidemiological characteristics of CDI patients will help to support public health decision-making.