Sahih Muslim , Book 22, Hadith 4823 (USC-MSA)

Al-Bara' reported: My maternal uncle Abu Burda sacrificed his animal before ('Id) prayer. Thereupon Allah's Messenger said: That is a goat (slaughtered for the sake of) flesh (and not as a sacrifice on the day of Adha). He said: I have a lamb of six months. Thereupon he said: Offer it as a sacrifice, but it will not justify for anyone except you, and then said: He who sacrificed (the animal) before ('Id) prayer, he in fact slaughtered it for his own self, and he who slaughtered after prayer, his ritual of sacrifice became complete and he in fact observed the religious practice of the Muslims.

وَحَدَّثَنَا يَحْيَى بْنُ يَحْيَى، أَخْبَرَنَا خَالِدُ بْنُ عَبْدِ اللَّهِ، عَنْ مُطَرِّفٍ، عَنْ عَامِرٍ، عَنِ الْبَرَاءِ، قَالَ ضَحَّى خَالِي أَبُو بُرْدَةَ قَبْلَ الصَّلاَةِ فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ تِلْكَ شَاةُ لَحْمٍ ‏"‏ ‏.‏ فَقَالَ يَا رَسُولَ اللَّهِ إِنَّ عِنْدِي جَذَعَةً مِنَ الْمَعْزِ فَقَالَ ‏"‏ ضَحِّ بِهَا وَلاَ تَصْلُحُ لِغَيْرِكَ ‏"‏ ‏.‏ ثُمَّ قَالَ ‏"‏ مَنْ ضَحَّى قَبْلَ الصَّلاَةِ فَإِنَّمَا ذَبَحَ لِنَفْسِهِ وَمَنْ ذَبَحَ بَعْدَ الصَّلاَةِ فَقَدْ تَمَّ نُسُكُهُ وَأَصَابَ سُنَّةَ الْمُسْلِمِينَ ‏"‏ ‏.‏

sunnah.com