RABBI JOSEPH KRESEFSKY answers ...
G_d IS omniscient. He does know the beginning and the end.
Ps. 139:16 – “Your eyes could see me as an embryo, but in your book all my days were already written; my days had been shaped before any of them existed.”
Or consider many of the Messianic Prophecies:
Be hated without cause- Is. 49:7, Ps. 69:4, Fulfillment -John 15:24-25
Be betrayed by a friend- Ps.41:9, 55:12-14, Fulfillment – Mt. 26:21-25;47-50, John 13:18-21, Acts 1:16-18
Be sold for 30 pieces of silver- Zech. 11:12 Fulfillment – Mt. 26:15