64 We cannot, then, doubt that the knowledge of God depends on the occasion and not on any change on His part: by the occasion being meant the occasion, not of obtaining but of declaring knowledge, as we learn from His words to Abraham, Lay not your hand upon the lad, neither do thou anything unto him, for now I know that you fear your God, and hast not withheld your beloved son, for My sake. God knows now, but that now I know is a profession of previous ignorance: yet it is not true, that until now God did not know the faith of Abraham, for it is written, Abraham believed in God, and it was counted to him for righteousness, and therefore this now I know marks the time when Abraham received this testimony, not when God began to know. Abraham had proved, by the sacrifice of his son, the love he bore to God, and God knew it at the time He spoke: but as we cannot suppose that He did not know before, we must for this reason suppose that He took knowledge of it then because He spoke.
By way of example, we have chosen for our consideration this passage out of many in the Old Testament, which treat of the knowledge of God, in order to show that when God does not know, the cause lies, not in His ignorance, but in the occasion.
Source: On the Trinity (New Advent)