Here is a detailed description of the account in the Vinaya Pitaka where the Buddha says Buddha Dhamma will FLOURISH only for 500 years:
“20. Nuns (Bhikkhunī)”
– There is also the “Gotamī Sutta (AN 8.51)” that summarizes the above account.
But that does not mean Buddha Dhamma would have disappeared after 500 years.
– As the reference given by Tobias points out, the Buddha said that “the Buddha Sasana will survive in the human realm as long as the Noble lineage survives (meaning as long as there are Sotapannas).
– That is in the “Mahāparinibbāna Sutta (DN 16)” toward the end: “Yasmiṁ kho, subhadda, dhammavinaye ariyo aṭṭhaṅgiko maggo na upalabbhati, samaṇopi tattha na upalabbhati. Dutiyopi tattha samaṇo na upalabbhati. Tatiyopi tattha samaṇo na upalabbhati. Catutthopi tattha samaṇo na upalabbhati. Yasmiñca kho, subhadda, dhammavinaye ariyo aṭṭhaṅgiko maggo upalabbhati, samaṇopi tattha upalabbhati, dutiyopi tattha samaṇo upalabbhati, tatiyopi tattha samaṇo upalabbhati, catutthopi tattha samaṇo upalabbhati. Variant: ca → idheva (mr)Imasmiṁ kho, subhadda, dhammavinaye ariyo aṭṭhaṅgiko maggo upalabbhati, idheva, subhadda, samaṇo, idha dutiyo samaṇo, idha tatiyo samaṇo, idha catuttho samaṇo, suññā parappavādā samaṇebhi aññehi.
–Ime ca, subhadda, bhikkhū sammā vihareyyuṁ, asuñño loko arahantehi assāti.”
That means: “Subhadda, in whatever teaching and training the noble eightfold path is not found, there is no true Sotapanna, no Sakadagami, no Anagami, and no Arahant found. In whatever teaching and training the noble eightfold path is found, there is a true Sotapanna found, a Sakadagami, an Anagami, and an Arahant found. In this teaching (Buddha Dhamma) and training (Vinaya) the noble eightfold path is found.
– As long as bhikkhus maintain the Ariya lineage, this world will have Arahants.”