“The function of prayer is not to influence God, but rather to change the nature of the one who prays.”
This quote from Kierkegaard can be found in: “An Occasional Discourse: On the Occasion of a Confession: Purity of Heart is to Will One Thing” which is a discourse part of the larger work “Upbuilding Discourses in Various Spirits.” However, it has also been published separately.
Here follows another slightly different translation from the Danish: “The prayer does not change God, but it changes the one who offers it”.