Grain, crushed or whole will last years. It is the sugars and starches that we are after, that will pretty much stay stable. Given adverse conditions, crushed will deteriorate quicker than whole.
Grain is dried to a level that will keep the grain stable, and mold will not grow. It is drier than most household environments. The biggest enemy that you have is humidity and moisture in the air. If kept sealed it should last a long time. Any exposure to the environment will slowly cause the grain to get 'less dry' and more prone to mold and deterioration. Crushed grain having more surface area is obviously more prone to deterioration.
Diastatic power is probably the most susceptible to deterioration. Not sure I would trust crushed base grain after a few months (maybe if there wasn't much specialty malt in the mash it would be OK). Whole grain if stored well, should be fine for 18 months, maybe a couple of years. Problem is; you can't measure diastatic power .... the longer you keep the grain, the greater you risk issues with conversion.
I'm sure there are tales of people who have kept sealed grain for 10+ years and brewed fine, but there are probably others where people using grain after a few years have been trying to figure out why their mash efficiency was low.
Specialty grain should last for years, crushed or whole since you are really only after the sugars and flavor.