The Prophet ﷺ said, "When one of you is invited to a meal while he is fasting, let him say, 'I am fasting.'"
حدثنا نصر بن علي حدثنا سفيان بن عيينة عن أبي الزناد عن الأعرج
عن النبي ﷺ قال إذا دعي أحدكم وهو صائم فليقل إني صائم
Muslim also narrated it in the Book of Fasting, chapter on it being recommended for the fasting person, if invited to a meal and not wishing to break the fast, to say... etc., hadith no. 1150, from the hadith of Sufyan bin Uyayna, with the same wording.