2 Samuel 24:8

So when they had gone through all the land, they came to Jerusalem at the end of nine months and twenty days.

Those carrying out the census went through all the land and came back to Jerusalem at the end of nine months and twenty days. The numbering was a long work that was still unfinished when David was convicted of his sin. The census grew out of prosperity and pride, after Israel had increased in numbers, wealth, and greatness under David until the people became exalted, forgot the Giver of all mercies, and lost the peculiar holy character that separated them from the surrounding nations. David failed to keep the humility and trust in God of his earlier life, but looked on the growth of the kingdom with pride, contrasted its present prosperous strength with its former fewness and weakness when he took the throne, and took glory to himself. In ambition he yielded to the temptation of the devil to number Israel so that he could compare the two conditions.

The effort to count the people was an expression of selfishness. Numbering Israel instead of working according to God's order displeased God and was contrary to His express command. The act led Israel to rely on strength of numbers instead of the living God. While the work was still unfinished, David saw his error, was convicted that he had committed a great sin against God in foolishly numbering the people, and humbled himself before God in confession of his folly. His repentance came too late to turn back the judgment, for the word had already gone forth to the prophet with a choice of punishments, and David chose to fall into the hands of a merciful God rather than be left to the cruel mercies of wicked men. In contrast to this selfish counting, God's freely offered gift of eternal life is open to all who receive Christ.