What city do you live in? If you have a small local coffee roaster, you’ll have the best results (BY FAR) if you buy freshly roasted beans from them and grind them at home. Only grind what you need each day to keep the rest of the beans fresh. You can find out which days the shop puts new batches on the shelf and buy them within a day or two of when they hit the shelf. The bag should have the roast date on it. In my experience, beans are best within the first 5 to maybe 8 days after roasting, and then start going stale, much like any other dry goods sitting on your counter (crackers, bread, etc.). Not that you can’t still use them, but the coffee won’t taste as good after about a week.
If you don’t have a local roaster, you can mail-order from many number of fine roasteries throughout country, and beans that are no more than a couple days old will arrive at your doorstep. Storyville, Kuma, Zoka, Herkimer, or Vivace in Seattle, Intelligentsia in Los Angeles and Chicago(?), Sump Coffee in St. Louis, and the list goes on.
Give up on mass-produced beans bought at the grocery store and try giving your business to a small roastery. (and Starbucks doesn’t count) You won’t be disappointed!