If comapny x announces dividends will be paid out tomorrow, can I buy 1000 shares today, collect my dividend on the shares, and then sell? Or do you have to hold the stock for a period of time before you can sell?
The timing works like this:
The board announces that the shareholders of record as of the "record date" will be paid a dividend on "payment date".
On the "ex date" the stock stops trading "cum dividend" and starts trading "ex dividend". If you buy the stock before, then you'll be a shareholder of record on the record date and will receive the dividend - even if you are the shareholder of record for a very short time at the right moment. But if you buy the stock after, then you will not be a shareholder of record on the record date and will not receive the dividend. Rather, whoever sold you the stock will still be a shareholder of record and will still receive the entire dividend instead. You are the shareholder of record or you are not. You get all of the dividend or nothing. The dividend is not pro-rated.
The prior day's closing price includes the dividend, while the ex date's opening price does not include the dividend.
Finally, the shareholders receive the cash on the payment date. Be careful not to spend it until you actually receive it.
(See also https://www.investopedia.com/terms/d/dividend-selling.asp Investopedia and https://www.nasdaq.com/market-activity/dividends for example.)