The answer is different for each spice and grind. Most sources I have seen suggest that 6 months is the long case for 'fresh spices', but all suggest grinding in small quantities so that you will not need for them to last that long.
Following is some information from "Spice Mogul", some basic "Do's and Don'ts"
Do
* Buy spices whole, versus ground, whenever possible.
* Buy in quantities that you will likely use up in 6 months time.
* Mark the date you buy your spices and dried herbs. If there are no dates on the package, take a marker and date each container when opened.
* Grind spices just before using. Grinding releases the volatile compounds that give a spice its flavor and aroma. The longer the spice sits around (either whole or ground), the more the compounds disappear and the flavors lessen.
Don’t
* Store spices and herbs on the counter or close to the stove. Remember that just like with oils, heat, light, and moisture are enemies of a spices flavor and shelf life. Cool, dry and dark should be your watch words.
* Forget to check for freshness.
* Use pre-ground spices if you can avoid it. If you must, test for flavor by rolling a small amount between your fingers and taking a whiff. If it releases a distinct aroma, you’re ok. If you have to strain to smell it, pitch it and buy fresh. There is no sense in ruining a dish full of other ingredients because your spices are not up to their full strength.
Spice Mogul also has a good collection of specific advice that you may wish to review.