"To ensure that you are in the record books, you need to buy the stock at least three business days before the date of record, which also happens to be the day before the ex-dividend date."

http://seekingalpha.com/article/765801-how-ex-dividend-dates-work