The XD date is the day when a share price is marked as ex-dividend. The day before the XD date the holder of the shares is entitled to receive the dividend. If you buy the shares on the XD date, you are not entitled to receive the dividend and, if it does get paid to you by mistake, you have to give it back. Fortunately this does not happen much as companies pay dividends to whoever is on the register on the record date