Hadithcore
Mishkat al-Masabih, 743

Al-Hasan reported in <i>mursal</i> form that God's Messenger said, “A time is coming when people will talk in their mosques about their worldly affairs, so do not sit with them, for God has nothing to do with them.” Baihaqi transmitted it in <i>Shu'ab al-iman</i>.

وَعَنِ الْحَسَنِ مُرْسَلًا قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «يَأْتِي عَلَى النَّاسِ زَمَانٌ يَكُونُ حَدِيثُهُمْ فِي مَسَاجِدِهِمْ فِي أَمْرِ دُنْيَاهُمْ. فَلَا تُجَالِسُوهُمْ فَلَيْسَ لِلَّهِ فِيهِمْ حَاجَةٌ» . رَوَاهُ الْبَيْهَقِيّ فِي شعب الْإِيمَان

References1 variant
In-Book Reference
Book 4, Hadith 171