Dividends on stocks, mutual funds and ETFs can enhance your investment return and can provide income in retirement. Most dividends are paid quarterly, but many ETFs pay monthly dividends. Some also get preferential tax treatment, in that they are not taxed at your normal income tax rate, depending on your tax bracket. See this article for more information on that.
A dividend payment procedure follows a chronological order of events and the associated dates are important to determine the shareholders who qualify for receiving the dividend payment.
Announcement Date: Dividends are announced by company management on the announcement date, and must be approved by the shareholders before they can be paid.
Ex-dividend Date: The date on which the dividend eligibility expires is called the ex-dividend date or simply the ex-date. For instance, if a stock has an ex-date of Monday, May 5, then shareholders who buy the stock on or after that day will NOT qualify to get the dividend as they are buying it on or after the dividend expiry date. Shareholders who own the stock one business day prior to the ex-date - that is on Friday, May 2, or earlier - will receive the dividend.
Record Date: The record date is the cut-off date, established by the company in order to determine which shareholders are eligible to receive a dividend or distribution.
Payment Date: The company issues a payment of the dividend on the payment date, which is when the money gets credited to investors' accounts.
Note that usually the ex-date and record date are either the same or within a day or two. However, most brokerage firms, such as Schwab, require a couple of business days to record your purchase of the stock, so if you purchase it on the record date, you may not be included in that dividend. This is called the settlement date when you purchase your stock. You can check with your brokerage for their requirements.
If I'm buying a stock and want the the next dividend, I normally buy it at least three days before the record date, which will be included in the announcement.
For example, here's a recent announcement for Spark Energy's quarterly dividend, which pays a 7+ percent annual dividend.
Regular Dividend of $0.1813 to go Ex: SPKE trades ex-dividend Thursday (5/30/2019) and will be payable to shareholders of record as of 05/31/2019 on 6/14/2019.
On the flip side, if I sold the stock after the record date, but before the payment date, I'd still receive the dividend. For more information see this article at Investopedia, which by the way, is a great source of information. Happy investing!