It is narrated from Sayyiduna Anas bin Malik (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "Indeed, a man spends a long period of his life doing deeds such that if he died in that state he would enter Paradise, but then before his death he changes and begins doing the deeds of the people of Hell, so he dies and enters the Fire. And indeed a person spends a period of his life doing deeds such that if he died upon them he would enter Hell, then before his death he changes and begins doing the deeds of the people of Paradise, then when he dies he enters Paradise."
Thus Musa bin Isma'il narrated it from Hammad.
Whereas Yazid bin Harun, Affan bin Muslim and Ibrahim al-Sami narrated it from Hammad bin Salamah, from Humayd, from Sayyiduna Anas (may Allah be pleased with him), but these narrators did not mention al-Hasan al-Basri (may Allah have mercy on him) (in the chain).
Likewise Wuhayb bin Khalid bin Ajlan al-Basri and Khalid bin Abdullah al-Tahhan al-Wasiti narrated it from Humayd, from Sayyiduna Anas (may Allah be pleased with him).
And Muhammad bin Abi Adi narrated it from Humayd, from Sayyiduna Anas (may Allah be pleased with him), as mawquf (from the Companion), and he also said: "Humayd once narrated it as marfu' (attributed to the Prophet (peace and blessings be upon him)), then he stopped doing so."
A supporting narration for this hadith is found in the Sahihayn in the hadith of Sayyiduna Ibn Mas'ud and Sayyiduna Sahl bin Sa'd (may Allah be pleased with them).