ANSWER: The phrase you are referring to, the "ancient of days," only occurs three times in the entire Bible. All these occurrences show up in the book of Daniel, the seventh chapter, in verses 9, 13 and 22. The reference in verse 13 is most interesting.
13. I saw visions in the night and, behold, One like the Son of man came with the clouds of heaven, and came to the Ancient of Days . . . (Daniel 7:13, HBFV throughout)
Verse 13 refers to two distinct Beings, one is called 'the Son of man', and the other is the one referred to in your question. King David, more than three hundred years before Daniel wrote these words, spoke of these two individuals when he wrote the following.
1. The LORD said unto my Lord, "Sit at My right hand until I make Your enemies as Your footstool" (Psalm 110:1)
This verse in Psalm 110 references three people, although in English it is a bit confusing since the same word is used to reference two distinct individuals. There is David, who is the narrator. There is "the Lord" (Strong's Concordance #H3068) which in the Hebrew is the word Jehovah. Then there is "my Lord" (Strong's #H113), which in the Hebrew is Adoni. The word Adoni means sovereign or master.
Who is David's Lord in Psalm 110? We find our answer in the New Testament. The focus of the first chapter in Hebrews is Christ and establishing the fact that he is the Savior of Man. The chapter uses the same verse found in Psalm 110.
1. God, Who spoke to the fathers at different times in the past and in many ways by the prophets, has spoken to us in these last days by His Son (Jesus) . . . 13. But unto which of the angels did He ever say, "Sit at My right hand, until I make Your enemies a footstool for Your feet"?
Clearly, the "my Lord" of Psalm 110 was the Being who became Jesus Christ. Who, then, was the other Being who was Lord OVER David's Lord? It is whom we refer to as God the Father. Jesus himself testified to the fact that the Father was greater than or over him (John 10:29, 14:28).
Psalm 110 and Daniel 7 refer to the same two Beings in the Godhead. "My Lord" of Psalm 110 is the same as the "Son of man" in Daniel 7. Jesus is referred to as the "Son of Man" in more than eighty distinct verses in the four gospel accounts. The Lord (Jehovah), who is the first Being listed in the Psalm, is the same as the "Ancient of Days" Daniel recorded.
There is something else to note in the scriptures we covered. They show (among many other Bible verses) that the Godhead is currently composed of TWO (the Ancient of Days and the Son of Man), not three, Beings. Noticeably absence is any mention of a third entity called the "Holy Spirit." This is because, in spite of the rhetoric from Protestants and Catholics, God is NOT triune in nature. The Holy Spirit is not a person but the POWER by which the Father and the Son accomplish their will. For more information on this subject, please see our article "Is God a Trinity?"