When a company declares a dividend, it sets a record date: the day you must be on its books as a shareholder. The exchange then sets the ex-dividend date. According to the SEC's Investor.gov, the ex-dividend date for stocks is usually the same day as the record date, or one business day earlier if the record date is not a business day.
Rule
buy before the ex-dividend date → you receive the dividend
buy on or after the ex-dividend date → the seller receives it
Example
Investor.gov's example: a dividend declared Monday, March 2, 2026, with a record date of Monday, March 16, 2026, has an ex-dividend date of March 16. Someone who buys on March 13 gets the dividend; someone who buys on March 16 does not. If the record date had been Sunday, March 15, the ex-dividend date would move back to Friday, March 13.
Why it matters for tax
The ex-dividend date anchors the qualified dividend holding period: you must hold the shares more than 60 days during the 121-day window that starts 60 days before it (IRS Publication 550). Buying just before the ex-date and selling soon after usually turns the dividend into an ordinary dividend.
More in how are dividends taxed.