Coffee is not the type of product that will carry an 'enjoy by' date. It is, however, becoming more and more common to see a 'roasted on' date printed on bags of beans. For the home coffee craftsman, this can be a very useful piece of information to take into account. It isn't like a perishable food product that might actually kill you if it is a little past its prime, but there is a window of ideal aromatic freshness that the consumer should know.
Coffee that is too far from roast will taste flat
It is easy to grasp the concept that aging coffee will begin to taste less exciting and more 'stale.' The big question is, "When does this actually happen?" Even when coffee is heat-sealed with a one-way-valve, aromatic loss begins to be noticeable somewhere between 7 and 30 days. This may seem like a large range, but it is honestly hard to define since many coffees seem to be more resilient due to things like bean density and roast style. Your best bet is to use your coffee within 14 days after roast, but it is probably not going to noticeably degrade until you are well into the third or fourth week, if properly stored.
Coffee that is too close to roast will also taste flat
Believe it or not, coffee can actually be 'too fresh.' Coffee roasters all know that there is a rule of thumb to wait at least 24 hours from when a coffee is roasted to taste it. Again, it depends on characteristics like bean density and roast style, but peak aromatics are actually not experienced until the 3rd or 4th days, due to outgassing of carbon dioxide. The carbon dioxide affects how well coffee extracts, so resting is essential. Resist the urge to purchase the coffee that is being roasted the day you are purchasing it, unless you are planning on letting it rest for a couple days.
The ideal window
The trick is to find the range where the carbon dioxide is minimized but the aromatics are maximized. As a rule, the ideal neighborhood is between 3 and 10 days from roast date. If you are fortunate enough to live close to a roastery, this should be easy to accomplish. A weekly purchase that matches your consumption can be engineered very easily with these guidelines.
If your roaster doesn't include the roast date on the packaging, you might want to consider sourcing elsewhere. Roast date is a detail that should be important to you and the inclusion of this will reveal an attention to detail that qualifies a roastery. There are many national roasteries who offer mail service which will get you their product well within the ideal range of consumption while including their roasting date on their packaging.
Coffee is an aromatic product that is best consumed fresh. This freshness exists within a window of time that is neither too close nor too far from roast. A big part of brewing with confidence is knowing that your coffee is fresh. Source the best and brew the best.