It is narrated from Sayyiduna Ibn Abbas (may Allah be pleased with him) that when a woman gives birth after nine months, twenty-one months of breastfeeding suffice her; when she gives birth after seven months, twenty-three months of breastfeeding (that is, nursing the child) suffice her; and when she gives birth after six months, twenty-four months of breastfeeding suffice her, just as Allah Almighty has said: 'And his bearing and his weaning is thirty months' [Surah al-Ahqaf: 15].
Hadith Referenceالسنن الكبرى للبيهقي / كتاب العدد / 15548