What is the ex-date (Corporate Actions)?
The ex date is a date set by the Stock Exchange to mark a cut-off point for entitlements to Corporate Actions such as Rights Issues, and is usually at start of business that day, e.g. 8am.
Whoever holds the shares on this date is entitled to whatever is being offered. If you buy on this date you are not entitled as you did not hold at start of business that day (e.g. 8am) and therefore if you sell on this date, you retain the entitlement, as you did hold at 8am on the ex date.