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:36:40

It is not allowable for the sun to reach the moon, nor does the night overtake the day, but each, in an orbit, is swimming.  

It does not behove — it is ˹neither˺ facilitated nor is it right for — the sun to catch up with the moon, and so appear together with it at night, nor may the night outrun the day, and thus it ˹the night˺ never arrives before the latter ends and each (kullun: the nunation compensates for the ˹missing˺ genitive annexation ˹that would have been constructed˺ with al-shams, ‘the sun’, al-qamar, ‘the moon’, and al-nujūm, ‘the stars’) ˹of these˺ is in an orbit, swimming, moving — these ˹celestial bodies˺ are being treated as ˹though they were˺ rational beings.
القرآن:٣٦:٤٠

لَا الشَّمْسُ يَنْبَغِي لَهَا أَنْ تُدْرِكَ الْقَمَرَ وَلَا اللَّيْلُ سَابِقُ النَّهَارِ ۚ وَكُلٌّ فِي فَلَكٍ يَسْبَحُونَ  

{لا الشمس ينبغي} يسهل ويصح {لها أن تدرك القمر} فتجتمع معه في الليل {ولا الليل سابق النهار} فلا يأتي قبل انقضائه {وكل} تنويه عوض عن المضاف إليه من الشمس والقمر والنجوم {في فلك} مستدير {يسبحون} يسيرون نزلوا منزلة العقلاء.

See similar narrations below:

Collected by Qurʾān
quran:21:33

And it is He who created the night and the day and the sun and the moon; all ˹heavenly bodies˺ in an orbit are swimming.  

And He it is Who created the night and the day, and the sun and the moon, each (kullun, the nunation of this ˹particle˺ stands in place of the second noun ˹of the genitive construction˺ that would have been alshams, ‘the sun’, or al-qamar, ‘the moon’, or their subsidiaries, namely, al-nujūm, ‘the stars’) in an orbit, a circular ˹one˺ like a mill in the sky, swimming, moving with speed, like a swimmer in water. In order to effect the analogy with the latter, the plural person ˹of the verb employed˺ for rational beings is used.
القرآن:٢١:٣٣

وَهُوَ الَّذِي خَلَقَ اللَّيْلَ وَالنَّهَارَ وَالشَّمْسَ وَالْقَمَرَ ۖ كُلٌّ فِي فَلَكٍ يَسْبَحُونَ  

{وهو الذي خلق الليل والنهار والشمس والقمر كل} تنوينه عوض عن المضاف إليه من الشمس والقمر وتابعه وهو النجوم {في فلك} مستدير كالطاحونة في السماء {يسبحون} يسيرون بسرعة كالسابح في الماء، وللتشبيه به أتى بضمير جمع من يعقل.