Language:
كتاب القدر
82  
Divine Will (Al-Qadar)
(4)
Chapter: "And the Command of Allah is a decree determined"
(4)
Sahih al-Bukhari 6602

Narrated Usama:

Once while I was with the Prophet (ﷺ) and Sa`d, Ubai bin Ka`b and Mu`adh were also sitting with him, there came to him a messenger from one of his daughters, telling him that her child was on the verge of death. The Prophet (ﷺ) told the messenger to tell her, "It is for Allah what He takes, and it is for Allah what He gives, and everything has its fixed time (limit). So (she should) be patient and look for Allah's reward."

حَدَّثَنَا مَالِكُ بْنُ إِسْمَاعِيلَ، حَدَّثَنَا إِسْرَائِيلُ، عَنْ عَاصِمٍ، عَنْ أَبِي عُثْمَانَ، عَنْ أُسَامَةَ، قَالَ كُنْتُ عِنْدَ النَّبِيِّ صلى الله عليه وسلم إِذْ جَاءَهُ رَسُولُ إِحْدَى بَنَاتِهِ وَعِنْدَهُ سَعْدٌ وَأُبَىُّ بْنُ كَعْبٍ وَمُعَاذٌ أَنَّ ابْنَهَا يَجُودُ بِنَفْسِهِ‏.‏ فَبَعَثَ إِلَيْهَا ‏ "‏ لِلَّهِ مَا أَخَذَ، وَلِلَّهِ مَا أَعْطَى، كُلٌّ بِأَجَلٍ، فَلْتَصْبِرْ وَلْتَحْتَسِبْ ‏"‏‏.‏
Reference : Sahih al-Bukhari 6602
In-book reference : Book 82, Hadith 8
USC-MSA web (English) reference : Vol. 8, Book 77, Hadith 599
  (deprecated numbering scheme)