This is a hyphen: –
This is a dash: —
A common mistake is referring to a hyphen as a dash, or using a hyphen within a sentence when there should be a dash. The one difference between the two that is obvious right away is that a dash is about twice as long as a hyphen. But there is also a difference in how each functions as punctuation.
A hyphen is most commonly used for compound nouns or adjectives, like mother-in-law (noun) and old-fashioned (adjective).
A dash is often used as an interjection within a sentence. When used this way, dashes sometimes appear in pairs similarly to how commas are used in pairs to set apart nonessential descriptive phrases (appositives). When dashes are used this way, they are like interjections within a sentence.
Dashes can also be used like parentheses, or as colons before listing a series of items.
Example 1: The rain made for a cool—albeit dreary—day for outdoor activities.
Example 2: We went shopping for several items for making sandwiches—bread, peanut butter, jam, and honey.
To make the distinction between hyphens and dashes more confusing is the fact that there are two types of dashes: the em dash and the en dash
The one we usually refer to as just a dash is the em dash.
There is also the en dash (–), which is used to indicate a range, like 1–10. It is wider than a hyphen but narrower than an em dash.