2 Samuel 5:4

4David was thirty years old when he began to reign, and ahe reigned forty years.

1 Chronicles 29:26-27

The Death of David

26Thus David the son of Jesse reigned over all Israel. 27The btime that he reigned over Israel was forty years. He reigned seven years in Hebron and thirty-three years in Jerusalem.
Copyright information for ESV