Coffee is perishable, just like fresh fruit and vegetables.
Beans are at their peak flavor for 24 to 72 hours after roasting. Carefully stored, whole roasted beans may keep up to 4 weeks. Ground coffee should be brewed within 1 to 2 weeks. Coffee easily picks up flavors of other foodstuffs, so keep it away from strongly flavored foods and spices. If stored beans seem to have lost their aroma and oily appearance, they probably should be tossed.