Internal evidence suggests Solomon penned this book (Ecclesiastes) in his old age. First Kings 11 tells us that during that time the king abandoned Yahweh to worship the pagan deities of his foreign wives. Ecclesiastes is more than just philosophy. It is the heart cry of a believer who has lost his way and is desperately searching for meaning in a life bereft of God. It is significant that nowhere in this book does the Teacher use the personal name of God revealed to Israel, Yahweh. Rational thought does lead to the author’s conclusion that God exists and created the universe, but it cannot lead anyone to saving faith apart from that revelation Solomon chose to reject.
Richards, L. O. (1991). The Bible reader’s companion (electronic ed., p. 397). Wheaton: Victor Books.