Introduction: Treatment of osteoporosis is focussed on the prevention fragility fractures, fractures of the hip being those which produce the highest rates of morbidity and mortality. The existence of a previous fracture is an important predictor of a new fracture. Objective: we intend to analyse how treatment for osteoporosis varies before and after a hip fracture. Material and methods: Using the 4,126,030 clinical records in the database for pharmaco-epidemiological research in primary care (Base de Datos para la Investigación Farmacoepidemiológica en Atención Primaria [BIFAP]) 2011 for the whole of Spain, information was obtained regarding patients who had a first hip fracture recorded between 2005-2011, having been monitored for at least a year before and after. We analyse the previous and subsequent treatment for osteoporosis (including calcium and vitamin D supplements). Results: 2,763 patients over 60 years of age (average 81 years) had suffered a hip fracture, of whom 81.6% were women. Before the fracture 26.5%(95% confidence interval [CI]: 24.8-28.1%) had received some antiosteoporotic treatment, of which 12%(95% CI: 11.0-13.5%), were bisphosphonates. 38.6%(95% CI: 36.8-40.4%) received treatment after the fracture, 20.4%(95%: 18.9-22%) treated with bisphosphonates. The factors associated with the initiation of treatment after the fracture were being a woman, being younger and having a previous diagnosis of osteoporosis. Conclusions: Most of the patients studied were not receiving preventative treatment before their hip fracture. After the fracture the prescription of treatment increased a little. The drugs most commonly added were calcium, vitamin D and bisphosphonates.