You need to purchase the stock one day or more before the ex-dividend date to receive the dividend.