Buying: You must buy one-day prior to the Ex-Div date (or sooner) to be an owner on the record date to receive the dividend. (This is because transactions take 3-days to settle) Shares bought on the Ex-Div date or later miss the record date and forfeit the dividend.
Selling: Shares sold prior to the Ex-Div date are not eligible to receive the dividend because you will not own them on the record date. Shares sold on or after the Ex-Div date will receive the dividend. This is because on Ex-Div date, the share price is reduced by the amount of the dividend to reflect the distribution.
There is often confusion over this because Ex-Div and Record dates are two days apart but newly purchased shares take three days to settle. You are not considered to own the shares until they have settled. Therefore, buying one-day prior to Ex-Div is the same as buying three days prior to the Record date. With most web sites, reference is always made to the Ex-Div date with regard to purchases and dividend payments even though distributions don't actually appear in your account until the Pay date.
"You are not considered to own the shares until they have settled."
Really? So if I buy a stock on Monday, because it doesn't settle until Thursday, if I sell it on Tuesday or Wednesday, who gets the gain or loss? If you are correct, I don't, because I don't own it until Thursday.
Want to really THANK you. I essentially knew the above, certainly the buy before the x date to get the divy but was a little uncetain of when I could sell to still get the divy. You confirmed what I thought; to wit that I would still get the divy if I sold on the xdate. But the reason I am thanking you is I have never seen a better clearer explanation. Wish I could keep this response in my records for posterity to refresh my recollection. Again, thank you as I do a lot of investing, both in spec stocks and in divy stocks and sometimes on the divy side I do cut it close. Again, THANKS