There is more to it than that. The packaging is one aspect. The exposure to moisture and air is another. Sell by dates are usually generated from experience. There is a legal side to this. With normal use a product will degrade to some extent. The sell by date is usually the date that leaves just enough time to consume or use the product in normal use.
This is a tough discussion. The use by date is generated among similar lines. It will be clear however that if you buy a product and start using it long before the "use by" date you are not guaranteed that the product will still be usable by the time the "use by date" comes along.
Many products are now labeled: use x amount of time after opening.
On the whole common sense should prevail. If something does not look or smell right that is usually an indicator that something can no longer be used.
In one of the other discussions (I believe on flour) similar remarks were made. There have been instances of grain which, after being interred thousands of years ago, was still perfectly usable.
It will be clear that it is practically impossible to have an accurate sell by date on simple inorganic compounds like refined salt (in principle it would be more than a human lifetime).