According to 2 Samuel 7:1, the events of this chapter take place after king David had settled into his palace (see 2 Samuel 5:11)1 and the Lord had given him rest from all his enemies. It is not clear if this rest refers to the battles which David won over the Philistines at the start of his Jerusalem reign (2 Samuel 5:17–25) or the later battles which he fought against multiple enemies (2 Samuel 8:1–18). Precise dating depends on when Hiram sent the necessary materials for David’s palace and when the ark was taken into Jerusalem. The fact that the Lord’s promise to David implies that rest had not been fully achieved (2 Samuel 7:9–11; see further 1 Kings 5:3–5) suggests that there were more battles to come.
1 Now when the king lived in his house and the LORD had given him rest from all his surrounding enemies,