Stock is classified as ex-dividend when it is no longer selling with a recently-declared dividend. At this point, the dividend has been assigned to the seller of the stock. It is quite common for the price of a company's stock to increase by the amount of a scheduled dividend as the ex-dividend date approaches and then decline immediately thereafter by the same amount, which reflects the decline in value of the shares to investors once the dividend has been paid. If the dividend is instead paid in stock, there may be no change in price, since there was no asset distribution.
The key date in calculating the ex-dividend date is the record date, which is the date on which an entity issuing dividends records the names of all investors holding the entity's shares, with the intent of paying the dividend to those investors. Because it takes two days to transfer ownership records when shares are sold, the various stock exchanges set the ex-dividend date to be two days prior to the record date. If the record date falls on a non-business day (such as a weekend or holiday), then count back two days from the immediately preceding business day to arrive at the ex-dividend date.
Thus, an investor who buys an entity's shares on or after the ex-dividend date will not receive any dividend that is declared but unpaid on that date. Conversely, the investor holding the shares immediately prior to the ex-dividend date will receive the dividend.