Language:
كتاب التمنى
94  
Wishes
(3)
Chapter: “If I had formerly known what I came to know recently…”
(3)
باب قَوْلِ النَّبِيِّ صلى الله عليه وسلم ‏"‏ لَوِ اسْتَقْبَلْتُ مِنْ أَمْرِي مَا اسْتَدْبَرْتُ ‏"‏
Sahih al-Bukhari 7229

Narrated `Aisha:

Allah's Messenger (ﷺ) said, "If I had formerly known what I came to know recently, I would not have driven the Hadi with me and would have finished the state of Ihram along with the people when they finished it."

حَدَّثَنَا يَحْيَى بْنُ بُكَيْرٍ، حَدَّثَنَا اللَّيْثُ، عَنْ عُقَيْلٍ، عَنِ ابْنِ شِهَابٍ، حَدَّثَنِي عُرْوَةُ، أَنَّ عَائِشَةَ، قَالَتْ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ لَوِ اسْتَقْبَلْتُ مِنْ أَمْرِي مَا اسْتَدْبَرْتُ مَا سُقْتُ الْهَدْىَ، وَلَحَلَلْتُ مَعَ النَّاسِ حِينَ حَلُّوا ‏"‏‏.‏
Reference : Sahih al-Bukhari 7229
In-book reference : Book 94, Hadith 4
USC-MSA web (English) reference : Vol. 9, Book 90, Hadith 335
  (deprecated numbering scheme)