To be entitled to receive dividends, stockholders must purchase the equities before the ex-date and hold them at least until the record date.
The cut-off date for purchasing shares to qualify for a corporate action or dividend is the trading day prior to the ex-date, before the market closes.
The record date, typically one business day after the ex-date, is when the company verifies the shareholder registry to determine who will receive dividends.