In my experience, for the most part, "המקום ינחם אתכם בתוך שאר אבלי ציון וירושלים" is said to a mourner specifically during shiv'a. However, I've heard some people say it after shiv'a, particularly the first time they speak to the mourner as a mourner. (Because I'm mostly unacquainted with that practice, I say something less formulaic if speaking to a mourner for the first time, e.g. "Hashem should give you nechama".) So my question is twofold:
Does halacha (or the minhag of any communities) say anything about this? Specifically, is "Hamakom…" restricted to shiv'a? (Or do any halachic sources say explicitly that it's not?)
(Especially if the answer to #1 is that halachic sources say nothing…) What's the convention? (This will depend on location, of course.)
אם לא נחמו תוך ז׳ ופגע בו תוך ל׳ — מביע לו ג״כ ברכת
תנחומין הנהוגה. ואחר ל׳ אומר לו רק ״תתנחם״. ועל אביו ואמו מנחמו כל
י״ב תרש (טוש״ע שם).
If he did not console him within the seven [days of mourning] and met him during shloshim, he should also also express the customary blessing of consolation. After shloshim he should only say "[May you] be consoled". [If one is mourning] for his father or mother,he should console him throughout the [first] twelve months.