Islam regulates the death event in a way that benefits both the dead and those who survive them. Mourning is allowable but without objection to the divine will or showing impatience. The Sunnah of the Prophet (peace and blessings be upon him) sets the guidelines for mourning in such a way that allows for human feelings, and at the same time, preserves religious principles. Indeed, the best guidance is that of the Prophet (peace and blessings be upon him).
Responding to your question, Sheikh Ahmad Kutty, a senior lecturer and an Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, stated:
The prescribed period of mourning for the dead in Islam is three days, as reported in a number of well-attested traditions from the Prophet (peace and blessings be upon him). The only exception is the mourning of a wife over her husband, which is for four months and 10 days.
So, there is no precedent in the Sunnah of the Prophet for the practice you mention, nor was it practiced by the pious generations after him. Hence, it is an innovation, which has crept into the Muslim community.
We are, however, to keep alive the memory of the dead through virtuous acts. Offering du`aa’ (supplication) for them, visiting their graves, praying for them, fostering their ties of kinship, giving charities, etc., are all considered good, as long as we do not fix a date of 7 , 14 , 40, etc. We have sufficiency in these practices; hence, we do not need to resort to innovations.