You have to hold the stock before it goes
ex dividend to qualify for the div. Once it goes ex, you can sell and still receive the div, the payment date has no bearing on it. If you bought on the 15th, the day it goes ex, you do not receive the div (as it is ex div).