At midnight I shall rise to give thanks to You Because of Your righteous ordinances.
NASB95
At midnight I rise to praise you, because of your righteous rules.
ESV
At midnight I will rise to give thanks unto thee because of thy righteous judgments.
KJV

Another exercise of sacred pleasure is the ways of the Lord! His portion was always satisfying to this holy man, and he was daily feeding upon it with fresh delight. There was no occasion for the painful restrictions and mortifications of a monastery to oblige him to self-denying observances. Much less was there any desire, by these extraordinary services, to work out a righteousness of his own, to recommend him to the favor of God. His diligence in this heavenly work was the spontaneous effusion of a heart "filled with the Spirit." Presenting the morning and the evening service "seven times a day," was not enough for him; but he must rise at midnight to continue his song of praise. These hours sometimes had been spent in overwhelming sorrow. Now they were given to the privileged employment of praise. Indeed it seems to have been his frequent custom to stir up his gratitude by a midnight review of the Lord's daily manifestations of mercy. A most exciting example—especially for the child of sorrow, when "wearisome nights are appointed to him," and he "is full of tossings to and fro unto the dawning of the day!" Thus "let the saints be joyful in glory; let them sing aloud upon their beds." We observe this Christian enjoyment under circumstances of outward trial. When "at midnight—their feet made fast in the stocks—Paul and Silas prayed, and sang praises to God:" they gave thanks, because of His righteous judgments.

We often complain of our lack of spirituality in the Divine life—how much our body hinders the ascent of the soul heavenwards—how often drowsiness overcomes our evening communion with our God; the "weakness of the flesh" overpowering the "willingness of the Spirit." But, after making all due allowances for constitutional infirmity, how far are we "instant in season and out of season" in the mortification of the flesh? Do we earnestly seek for a heart delighting in heavenly things? The more the flesh is denied for the service of God, the more we shall be elevated for the enjoyment, and realize the privilege of the work; and instead of having so often to mourn that our "souls cleave to the dust," we shall "mount upwards with eagles' wings," and even now by anticipation, take our place before "the throne of God and the Lamb." Such is the active influence of self-denial in exercising our graces, and promoting our comfort! Oh! how much more fervent would be our prayers— how much more fruitful in blessings—were they enlivened with more abundant delight in the 'angelic work of praise!' (Baxter.) The theme is always before us. The subject of the heavenly song should constantly engage our songs on earth—Jesus and His love—the "worthiness of the Lamb that was slain"—His "power, and riches, and wisdom, and strength, and honor, and glory, and blessing." Midnight wakefulness would be far sweeter than slumber; yes, night itself would be turned into day, did the judgments of God, as manifested in the glory of the Savior, thus occupy our hearts. Lord! tune my heart to Your praise, and then no time will be unseasonable for this blessed employment. Time thus redeemed from sleep will be an foretaste of the unwearied service of heaven.

He was not afraid of the robbers; he rose, not to watch his house, but to praise his God. Midnight is the hour for burglars, and there were bands of them around David, but they did not occupy his thoughts; these were all up and away with the Lord his God. He thought not of thieves, but of thanks; not of what they would steal, but of what he would give to his God. A thankful heart is such a blessing that it drives out fear and makes room for praise. Thanksgiving turns night into day, and consecrates all hours to the worship of God. Every hour is canonical to a saint.

The Psalmist observed posture; he did not lie in bed and praise. There is not much in the position of the body, but there is something, and that something is to be observed whenever it is helpful to devotion and expressive of our diligence or humility. Many kneel without praying, some pray without kneeling; but the best is to kneel and pray: so here, it would have been no virtue to rise without giving thanks, and it would have been no sin to give thanks without rising; but to rise and give thanks is a happy combination. As for the season, it was quiet, lonely, and such as proved his zeal. At midnight he would be unobserved and undisturbed; it was his own time which he saved from his sleep, and so he would be free from the charge of sacrificing public duties to private devotions. Midnight ends one day and begins another, it was therefore meet to give the solemn moments to communion with the Lord. At the turn of the night he turned to his God. He had thanks to give for mercies which God had given: he had on his mind the truth of verse fifty-seven, "You are my portion," and if anything can make a man sing in the middle of the night, that is it.

The righteous doings of the great Judge gladdened the heart of this godly man. His judgments are the terrible side of God, but they have no terror to the righteous; they admire them, and adore the Lord for them: they rise at night to bless God that he will avenge his own elect. Some hate the very notion of divine justice, and in this they are wide as the poles asunder from this man of God, who was filled with joyful gratitude at the memory of the sentences of the Judge of all the earth. Doubtless in the expression, "your righteous judgments," David refers also to the written judgments of God upon various points of moral conduct; indeed, all the divine precepts may be viewed in that light; they are all of them the legal decisions of the Supreme Arbiter of right and wrong. David was charmed with these judgments. Like Paul, he could say, "I delight in the law of God after the inward man." He could not find time enough by day to study the words of divine wisdom, or to bless God for them, and so he gave up his sleep that he might tell out his gratitude for such a law and such a Lawgiver.

This verse is an advance upon the sense of verse fifty-two, and contains in addition the essence of fifty-five. Our author never repeats himself: though he runs up and down the same scale, his music has an infinite variety. The permutations and combinations which may be formed in connection with a few vital truths are innumerable.