Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
bayhaqi:5467ʿIkrimah Sabʿ ʿAshrah 5467 > Abū ʿAlī al-Rūdhbārī > Abū Bakr b. Dāsah > Abū Dāwud > Naṣr b. ʿAlī from my father > Sharīk > Ibn al-Aṣbahānī > ʿIkrimah > Ibn ʿAbbās

[Machine] Translation: The Prophet ﷺ stayed in Mecca for seventeen (or eighteen) days, shortening the prayer and offering two rak'ahs. These narrations differ between seventeen and eighteen days, as you can see. The most authentic narration, in my opinion, is the one reported by Muhammad ibn Isma'il al-Bukhari in his Sahih. Abdullah ibn al-Mubarak also adopted this narration, and there is no disagreement about it.  

البيهقي:٥٤٦٧وَرَوَاهُ عَبْدُ الرَّحْمَنِ بْنُ الْأَصْبَهَانِيِّ عَنْ عِكْرِمَةَ سَبْعَ عَشْرَةَ 5467 أَخْبَرَنَا أَبُو عَلِيٍّ الرُّوذْبَارِيُّ أنبأ أَبُو بَكْرِ بْنُ دَاسَةَ ثنا أَبُو دَاوُدَ ثنا نَصْرُ بْنُ عَلِيٍّ أَخْبَرَنِي أَبِي ثنا شَرِيكٌ عَنِ ابْنِ الْأَصْبَهَانِيِّ عَنْ عِكْرِمَةَ عَنِ ابْنِ عَبَّاسٍ

أَنَّ النَّبِيَّ ﷺ أَقَامَ بِمَكَّةَ سَبْعَ عَشْرَةَ يَقْصُرُ الصَّلَاةَ يُصَلِّي رَكْعَتَيْنِ اخْتَلَفَتْ هَذِهِ الرِّوَايَاتُ فِي تِسْعَ عَشْرَةَ وَسَبْعَ عَشْرَةَ كَمَا تَرَى وَأَصَحُّهَا عِنْدِي وَاللهُ أَعْلَمُ رِوَايَةُ مَنْ رَوَى تِسْعَ عَشْرَةَ وَهَى الرِّوَايَةُ الَّتِي أَوْدَعَهَا مُحَمَّدُ بْنُ إِسْمَاعِيلَ الْبُخَارِيُّ فِي الْجَامِعِ الصَّحِيحِ فَأَخَذَ مَنْ رَوَاهَا وَلَمْ يُخْتَلَفْ عَلَيْهِ عَلَى عَبْدِ اللهِ بْنِ الْمُبَارَكِ وَهُوَ أَحْفَظُ مَنْ  

رَوَاهُ عَنْ عَاصِمٍ الْأَحْوَلِ وَاللهُ أَعْلَمُ