Most pantry staples last much longer than their printed dates suggest. The dates are quality indicators set by manufacturers, not safety cutoffs enforced by any agency. Used correctly, they save money and reduce waste.
Canned goods stored in a cool, dry place are typically safe for two to five years past the printed date, provided the can is not bulging, leaking, or severely dented. The quality slowly declines, but the food remains safe.
Dried goods like rice, pasta, beans, and oats can last for years. Whole grains contain natural oils that eventually go rancid, so store them in airtight containers and use within a year for best flavor. Brown rice keeps longer in the freezer.
Flour and sugar last indefinitely if stored sealed. Watch flour for insects and any off smell; if it passes both tests, it is fine to use.
When in doubt, use your senses. Smell, look, taste a small amount. Most spoiled food signals clearly that it is no longer good. Trust those signals more than the date on the label.