It is almost impossible to tell exactly how long dinosaurs lived, but educated guesses can be made by studying the lifespans of their descendants. This group includes modern alligators, tortoises, fish and birds. Scientists are studying the rings of dinosaur bones much like trees are studied for their rings.
The Tyrannosaurus Rex, for example, reached adulthood by approximately 19 years of age. The maximum known age of a T. Rex was 28 years old. The lifespans of other dinosaur descendants like tortoises were much longer. A modern turtle can live up to 120 years, so it stands to reason that their ancestors could live at least as long.