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.
quran:3:24

That is because they say, "Never will the Fire touch us except for ˹a few˺ numbered days," and ˹because˺ they were deluded in their religion by what they were inventing.  

That, turning away and rejection was, because they said, ‘the Fire shall not touch us, except for a number of days’, that is, for forty days ˹only˺, the length of time their forefathers worshipped the calf, after which it would end; and the lies they used to invent, in their saying this, have deluded them in their religion (wagharrahum fī dīnihim, ‘it has deluded them in their religion’, is semantically connected to mā kānū yaftarūna, ‘the lies which they used to invent’).
القرآن:٣:٢٤

ذَٰلِكَ بِأَنَّهُمْ قَالُوا لَنْ تَمَسَّنَا النَّارُ إِلَّا أَيَّامًا مَعْدُودَاتٍ ۖ وَغَرَّهُمْ فِي دِينِهِمْ مَا كَانُوا يَفْتَرُونَ  

{ذلك} التولي والإعراض {بأنهم قالوا} أي بسبب قولهم {لن تمسنا النار إلا أياما معدودات} أربعين يوما مدة عبادة آبائهم العجل ثم تزول عنهم {وغرَّهم في دينهم} متعلق بقوله {ما كانوا يفترون} من قولهم ذلك.