it will last at the most 3 weeks with proper care, but 2 weeks is usually the norm. Keep in fridge in a deli cup with cloth lid, the more moisture they lose the less will hatch, do not water them, they do not eat as pupae, they are living and need air, but nothing else. I have a care sheet on my site under feeder insects, just put cursor there and it will show up to click on, scroll down until u come to the flys.
A large fly order usually lasts about a month for me. A lot has to do with proper feeder care, but the most important factor (I've found) is product quality. A good batch should have ≈90% hatch rate. Usually at week 3, I hatch out remaining pupae and place a new order. The adults can live a surprising long time once hatched if kept properly.