On the Shabbat before the start of a new month, we announce the precise day of Rosh Chodesh (the beginning of the month) and bless the month just before mussaf.
The custom began in the Middle Ages. Community leaders wanted to be sure that everyone knew when Rosh Chodesh fell, so that they could say the right prayers. Shabbat is a good time to proclaim the day or days of the coming Rosh Chodesh as a large part of the community is present in the synagogue.
As a preface to the administrative task of informing people of the new month, the rabbis added the prayer of the talmudic sage Rav, a moving plea for a life of peace, sustenance, health and a life in which we love Torah”” (Berachot 17b). This is birkat hachodesh, a blessing for the new month. Many say that the prayer is an echo of the Kiddush Hachodesh ritual that took place in Temple times, when messengers who saw the New Moon would travel as fast as they could to Jerusalem, come before the Beth Din and announce “Mekudash, mekudash!” (“It is sanctified”).