The need for a temporary filling may stem from a small chip or a much more substantial loss of part of a tooth, or even from an opening that a dentist may make.
There is a very wide choice of materials for temporary fillings. Some are soft and meant to be easily removed. Others may last a very long time (up to or beyond a year). The answer depends on a combination of these factors.