You have to be the owner of record before the ex-dividend date , which is not the same day as the date the dividend is paid.
This also implies that if you sell on or after the ex-dividend date, you'll still get the dividend, even if you no longer own the stock.
Keep in mind, also, that the quoted price of the stock (and on any open orders that are not specifically marked as "do not reduce") on its ex-dividend date is dropped by the amount of the dividend, first thing in the morning before trading starts.
If you happen to be the first order of the day, before market forces cause the price to move, you'll end up with zero gain, since the dividend is built into the price, and you got the same value out of it -- the dividend in cash, and the remaining value in stock.
As pointed out in the comments (Thanks @Brick ), you'll still get a market price for your trade, but the price reduction will have had some impact on the first trade of the day.
Source: NYSE Rule 118.30 Also, remember that the dividend yield is expressed in annualized terms.
So a 3% yield can only be fully realized by receiving all of the dividend payments made by the company for the year.
You can, of course, forget about individual companies and just look for dividends to create your own effective yield over time.
But, see the final point...
Finally, if you keep buying and selling just to play games with the dividends, you're going to pay far more in transaction fees than you will earn in dividends.
And, depending on your individual circumstances, you may end up paying more in capital gains taxes.
money.stackexchange.com/users/25370/Kent A.
The market is not stupid.
It realises that a company is worth less after paying out dividends than before paying them.
(It's obvious, since that company has just given out part of its earnings.)
So after a company pays out dividends, its stock price normally drops approximately by the amount paid.
Therefore if you buy, get the dividend, and immediately sell, under normal conditions you won't make any profit.
money.stackexchange.com/users/24528/Zenadix
The ex-dividend date, prevents this, but people are still able to do this and this is an investment strategy.
There are some illiquid and immature markets where prices don't adjust.
In the options market people are able to find mispriced deep in the money calls to take advantage of the ex-dividend date.
It is called dividend capture using covered calls.
money.stackexchange.com/users/4833/CQM
The rest of the market knows when the dividends are paid out, and that will be reflected naturally in the share price.
That's why there is no way to consistently beat the market.
Because the market is other human beings, who's sum of knowledge is greater than any individual.
Everything in the stock market boils down to this in one way or another.
money.stackexchange.com/users/32363/wedstrom
Although the market discussion by other answers is correct, the tax structure of many developed nations (I am familiar with Canada in particular) offers a preferred tax rate for dividend income compared to taxable gains.
Consequently, if your portfolio is large enough to make transaction fees a very small percentage rate, this is a viable investment strategy.
However, as the preferred tax rate for dividends typically will catch up to that for capital gains at some cut-off point, there is a natural limit on how much income can be favourably obtained in this way.
If you believe your portfolio might be large enough to benefit from this investment strategy, talk to a qualified investment advisor, broker, or tax consultant for the specifics for your tax jurisdiction.
money.stackexchange.com/users/32736/Pieter Geerkens
I remember my Finance Professor at b-school answering this question: The next moment the dividend is paid
the total market cap is decreased by the amount paid
This makes sense as cash leaves company, the value of the company is decreased by exactly the same amount.
To summarise: the moment you paid dividend, the value of the stock is decreased by the same amount.
money.stackexchange.com/users/33905/Sergey Bushmanov
This investment strategy may have tax advantages.
In some countries, income received from dividends is taxed as income, whereas profits on share trades are capital gains.
If you have already exceeded your tax-free income limit for the year, but not your capital gains tax allowance, it may be preferable to make a dealing profit rather than an investment income.
These arrangements are called a bed-and-breakfast .
money.stackexchange.com/users/33920/Brian Hooper
What prevents investors from buying high yield stocks and selling them as soon as their dividend is paid out?   I guess I am confused:  If you know the yield and when the dividend will be paid out, why not buy a share an instant before the dividend is paid out and then sell it?  Do you have to have held the share for some amount of time to get the dividend?Is there too much volatility in the instant the dividend is paid out?
What prevents investors from buying high yield stocks and selling them as soon as their dividend is paid out?
money.stackexchange.com
<stocks><dividends><stock-dividend>
money.stackexchange.com/questions/54633
money.stackexchange.com/users/2192/Matt
After a company pays dividends, it's stock price normally drops. Therefore you won't make any money from selling it back. You will also pay transaction fees and possibly taxes. If you are the first order of the day, before market forces cause a price move, you will have zero gain, because the dividend is built into the price. Once a company has paid out dividends, its stock price normally drops by roughly the amount paid. If you subsequently buy, receive the dividend, and then sell straight away, you usually will not make any profit. If you continue to buy and sell to play games with the dividends, you will end up paying more in transaction fees than you will earn in dividends. In addition you may have to pay more capital gains taxes.
The  ex-dividend date is not the same day as the date the dividend is paid. If you are the first order of the day, before market forces cause a price move, you will have zero gain, because the dividend is built into the price. Once a company has paid out dividends, its stock price normally drops by roughly the amount paid. If you subsequently buy, receive the dividend, and then sell straight away, you usually will not make any profit. If you continue to buy and sell to play games with the dividends, you will end up paying more in transaction fees than you will earn in dividends. In addition you may have to pay more capital gains taxes.