The relation between the record and ex-dividend date is because of the T+2 system of settlement. If trade settles before the record date, only then the new investor will receive the dividend.