A Sell-By Date is the date by which an item should be sold.
If the item isn't sold by then, it's supposed to be removed ("pulled") from the shelves.
When a date is given in calendar format, it is called "open dating"; when it is a code that you need a cipher machine to break, it is called "closed dating" or "coded dating." "Closed dating" is usually used on shelf-stable items such as tins and boxes.
Dates are based upon assumed handling and storage conditions -- the actual span can be shortened by unexpected conditions, such as an electrical outage causing chillers to be without power, etc.
Goods are often still edible past the sell-by date -- up until their use-by date, if one is provided.
In North America, Sell-By Dates are rarely seen, and then mostly on fresh goods that only have a shelf life measured in days. It is usually indicated in plain date format.
AmericaIn America, package dating and pulling from shelves is only required by law on packaged baby and infant foods. Poultry must also carry a sell-by date, unless it already has a "pack date" on it. Some states require it on dairy products. Otherwise, it's voluntary -- both the dating, and the withdrawal from shelves.
In America, if a date in readable calendar format is printed on a package, it must be accompanied by an explanation of what kind of date it is.
CanadaA sell-by date appears to be required by law only on shucked fresh or frozen shellfish. Expiry dates have to be printed on fortified foods such as infant foods and nutritional supplements, and it is illegal to sell those past that date.
ChinaChina passed a law on 1 April 2000 requiring that all packaged retail food must state (in Chinese) both the date of production and the sell-by date. It applies to all food packaged in China, as well as food imported into China.
UKSell-By Dates are a guide to shop staff. They are sometimes labelled as a "Display Until" date.
It is not against the law to sell food that has past a "Sell By" date put on it. The main purpose for retailers is food quailty, rather than food safety. However, almost all food retailers in the UK use them heavily, and on the evening of the last day of something's sell-by date, will usually slash the item down to a fraction of its price just to shift it out of the store. Stores such as Tesco's and Sainsbury's usually have a section of their chillers reserved for perishable items that have reached their Sell-By Date on that date, to gather them all in one place for bargain hunters.
Popular belief in the UK holds that stores do this clearance only because it's against the law for them to have it in the store after this date. It's not, as stated above. Consumers are confusing Sell-By Dates with the law around Use-By Dates, which is much stricter.
"... advertising the shelf-life of products is a relatively recent innovation. Although the sell-by date was introduced by Marks and Spencer in the 1950s as a stock-control guide for store-room staff, it was not until 1973 that it appeared on the shelves in M&S food stores as "a guarantee of freshness". -- Johnston, Philip. 'Best-before' is well past its sell-by date. London: Daily Telegraph. 12 July 2010.