How long is wheat good for after harvest?
I can give you the traditional aproach my local mill uses:

Harvest season is just a few weeks per year. The mill will during that time buy the amount of grain they need for one year - from harvest to harvest. The grain gets sorted, tested, dried and cleaned if necessary, and is then put into storage. 

During the year, it gets milled. The two factors here are capacity and demand. A mill works year-round, it makes no sense to let the machines stand idle for a long time. So there is a maximum capacity they can process per year - and a good management won't buy more. Also, there are times of higher demand (think holiday baking) which need more flour to be milled in advance. The grain should rest for a few weeks after harvest for better quality. I'm no scientist, but I trust my miller on this.

A good mill will strive to sell the flour as soon as possible after it is milled, partly for economic, but mostly for quality reasons. While especially white flour won't spoil for months (recommended: one year), darker or especially whole grain flours get rancid quickly and quality decreases. (E.g. changes in taste and moisture content and enzymatic degradation which influence the baking process and results.)

The whole grains on the other hand can easily be stored for well over a year, multiple years in fact.



Big industrial mills work in a similar way, just on a way larger scale and the flour has a longer time from mill via stores to the customer.