You can't buy on the 18th and get the divy according to what tdameritrade told me today. You have to have bought the shares on or before the ex date. Which technically should be like 2 days prior to the divy date.
The Important Dates of a Dividend There are four major dates in the process of a company paying dividends:
Declaration date– This is the date on which the board of directors announces to shareholders and the market as a whole that the company will pay a dividend.
Ex-date or Ex-dividend date– On (or after) this date the security trades without its dividend. If you buy a dividend paying stock one day before the ex-dividend you will still get the dividend, but if you buy on the ex-dividend date, you won't get the dividend. Conversely, if you want to sell a stock and still receive a dividend that has been declared you need to sell on (or after) the ex-dividend day. The ex-date is the second business day before the date of record.
Date of record– This is the date on which the company looks at its records to see who the shareholders of the company are. An investor must be listed as a holder of record to ensure the right of a dividend payout.
Date of payment (payable date) – This is the date the company mails out the dividend to the holder of record. This date is generally a week or more after the date of record so that the company has sufficient time to ensure that it accurately pays all those who are entitled.