For an explanation of how dividends work and the dates to know regarding ownership and dividends, read this previous question.
Following the purchase of a stock, it typically takes three days for the stock to be in your account (settlement date). Therefore, you need to buy the stock at least three days before the record date in order to qualify for the dividend.
If you buy a share ex-dividend, you are still entitled to receive dividends, just not the upcoming declared dividend.
Speak to your financial advisor to find out whether you will qualify for the next dividend for the stock you are considering. Learn more about how stocks work.