Announcement Date and Effective Date when a company Dividend Declared?

in order to get dividends do i have to buy it before announcement date or effective date . what happen if i buy before announcement date and sell before effective date do still i get didvidend . plz tell me how to make sure i get dividend .

Please check this -