How long were the dinosaurs on earth for?

The first dinosaurs date back to around 240 million years ago and the main extinction event was 65 million years ago, though of course birds are still alive today and are living dinosaurs.