When it finally reaches its adult stage, the common housefly (or Musca domestica) tends to live for about two to three weeks, but can live up to a couple months. And if you consider the animal's entire life cycle, the housefly lives for days even before sprouting wings.
The fly does move through all four of its life stages fairly quickly – the World Health Organization says it takes 6 to 42 days for an egg to transform from larva to pupa to adult. Eggs take a few hours to hatch into larvae, which in turn take a couple days or weeks to develop. Once the larva becomes a pupa with a protective case around it, it takes 2 to 10 days to emerge from its shell as an adult.
Even after adulthood, it takes a few days for it to be able to reproduce.
They mayfly, which belongs to a different order of insects, also goes through multiple stages of development that lasts about a year. Mayflies lay their eggs in a body of water, where they typically gather on the bottom. They hatch into nymphs, which then undergo a number of molts before they make their way to the top of the water's surface as a subimago – a "pre-adult" with wings. The subimago eventually flies from the water to molt again before final adulthood. But the adults are not very long-lived: the digestive system stops working with the final molt, and the flies tend to die within a couple of days.