I sold stock purchased through an employee stock purchase plan, and the initial purchase was over 20 years ago. The dividends were reinvested throughout this period. To report the cost basis on the non-covered portion of the transaction, would I use the stock price for the date of the initial purchase, even though subsequent purchases through the dividend reinvestment would have been at different prices?
Ok ... a bit of schooling in cost basis is in order ... if the broker that sold the stock doesn't have this info then you will need to do some computing yourself ... you will add up the original cost basis + all the reinvested dividends (that bought more stock) for a total of the cost basis of all the stock you sold.
For instance if you bought the original 100 shares for $1000 and then they paid out $100 in dividends per year which buys another 10 shares per year and this continues for 10 years you would have a total of 200 shares at a cost basis of $2000.
The example really oversimplifies, especially if you are selling only a fraction of your holdings.
It would be highly unusual for a company to pay the same dividend for 20 years.
Even so, regardless, each reinvested dividend is a purchase and generates its own future gains (or losses).
If you keep selling portions, or sell everything, at some point the Long-Term/Short-Tern treatment kicks in (long term basis exhausted) and you have to know which reinvestments happened less than one year ago.
See 2018 IRS Pub 550 Investment Income and Expenses
page 41 Table 4-1 for a sample table showing
the 20 years of basis records that you should have been maintaining.
The text in that section describes how to track your basis over time.