Allah The Almighty says about breastfeeding in Qur’an as follows:
“Mothers suckle their children for two whole years if the fathers desire the suckling to be completed. The father is responsible for their food and clothing in the fair known way. None should be burdened with more than one can bear: neither the mother should be pressed, nor the father should be burdened. The same responsibility is for the heirs (if the father passed away). There is no harm if they wean the child by mutual consent and consultation (before two years). There is also no harm if you choose to hire a wet nurse, provided that you pay her fairly. Fear Allah and know that Allah surely sees whatever you do.” (Al-Baqarah / The Cow 2:233)
From the phrase “Mothers suckle their children for two whole years if the fathers desire the suckling to be completed”, we understand that the limit for breastfeeding a child is two years. It is also possible for the child to be weaned by mutual consent and consultation of the parents before that time. So it is understood from the verse that a two year old child should not be suckled anymore.