David had been the king of Israel for 40 years: He ruled for seven years in Hebron and for 33 years in Jerusalem.