Open the book of Kings and read: And the days that David reigned over Israel were forty years: seven years reigned he in Hebron, and thirty and three years reigned he in Jerusalem (1 Kings 2:11). Now open Samuel: In Hebron he reigned over Judah seven years and six months (2 Samuel 5:5).
Seven plus thirty-three is forty. But seven and a half plus thirty-three is forty and a half. Where did the missing six months go?
The sages of the Sanhedrin asked this question (Sanhedrin 107a) and answered it with a second question: what happened to David after Bathsheba, after Nathan the prophet stood over him and said, Thou art the man?
For six months, the tradition teaches, David was afflicted with leprosy. During those months the Shechinah departed from him. During those months the Sanhedrin kept their distance. He sat alone, scraping his skin, composing the psalm that carries his grief forward through every generation (Psalms 51:7): Purge me with hyssop, and I shall be clean; wash me, and I shall be whiter than snow. And again (Psalms 51:12): Restore unto me the joy of thy salvation. And still again (Psalms 119:79): Let those that fear thee turn unto me.
The Book of Kings quietly omits those six months. It will not count them as reign. A king who is not clean before God is not, for that span, a king at all.
David's psalms remember what the chronicle refuses to.