‘2Sa 12:22 And he said, “While the child was alive, I fasted and wept; for I said, ‘Who can tell whether the LORD will be gracious to me, that the child may live?’
2Sa 12:23 But now he is dead; why should I fast? Can I bring him back again? I shall go to him, but he shall not return to me.”
In 2 Samuel 12, God curses King David, targeting David’s newborn child, because David has murdered Uriah the Hittite and taken his wife. The child becomes ill, and David begins praying fervently.
The child dies, and King David cleans himself up and goes to worship God. The servants wonder why David has changed his demeanor so quickly. David declares because his son is dead. While his son was alive there was a chance of God listening to his prayer. But after the child was dead, there was nothing that could be changed.
King David is expressing a belief in an open future, and ability to affect God through prayer, and the finality of the past. King David is a presentist, believing the future is “not yet” and the past is settled. He sees God as acting in real time and able to be persuaded. This is a readily apparent belief in the Psalms attributed to David.’
source: Christopher Fisher, 2 Samuel 12:22-23 Commentary (godisopen).