The same-day and 30-day rules for shares, with examples
Last updated . Written by Divisio Capital. Figures checked against GOV.UK on 15 November 2026.
The short answer:
- Same day first: a sale is matched with shares of the same company bought on the same day.
- Then the next 30 days: then with shares bought in the 30 days after the sale, earliest first.
- Then the pool: only what is left is matched with your section 104 holding at its average cost.
When you sell shares, HMRC first matches the sale with shares of the same company you bought that day, then with shares you buy in the 30 days after it. Only the rest comes from your pool at its average cost. So if you sell and buy back within 30 days while UK resident, your gain is worked out against the buy-back price, not the price you first paid.
The order a sale is matched in
Shares of the same class in the same company are treated as identical, so HMRC's helpsheet HS284 sets which purchases a sale is matched with, in this order:
- Shares bought on the same day as the sale (the same day rule).
- Shares bought in the 30 days after the day of the sale (the bed and breakfasting rule), as long as you were resident in the UK when you bought them.
- Shares in the section 104 holding: your other purchases of that share, pooled at their average cost.
If those three do not cover all the shares sold, HS284 says the rest are matched with later purchases, earliest first. HMRC's Capital Gains Manual adds that the 30-day rule comes before every other rule except the same day rule, and that it only matches shares bought by the same person in the same capacity.
Sources: GOV.UK, HS284 Shares and Capital Gains Tax (2026) and HMRC's Capital Gains Manual, CG51560. Checked against GOV.UK on 15 November 2026.
Why the 30-day rule exists
Bed and breakfasting means selling shares and buying the same shares back a short time later. HMRC's Capital Gains Manual says people did this to trigger a gain that qualifies for some form of relief, or to trigger a loss while still meaning to hold the shares for the long term. It says the 30-day rule was brought in in 1998 to counter this. Where it applies, it normally reduces or removes the gain or loss the sale would otherwise have made.
Sources: HMRC's Capital Gains Manual, CG13350 and CG51560. Checked against GOV.UK on 15 November 2026.
A worked example: selling and buying back
You hold 2,000 shares in Company A in a general account (not an ISA). They are your section 104 holding, with a cost of £10,000, or £5.00 a share. Fees are left out to keep the sums clear.
On 3 November 2026 you sell 1,000 shares at £7.00, for £7,000. On 20 November 2026, 17 days later, you buy 1,000 back at £6.50, for £6,500.
| Proceeds: 1,000 × £7.00 | £7,000.00 |
| Cost: the 1,000 bought back at £6.50 | £6,500.00 |
| Gain | £500.00 |
| Pool afterwards: 2,000 shares | £10,000.00 |
The shares bought back are used up by the match and do not join the pool. The pool was never touched, so it still holds 2,000 shares at £5.00.
Now suppose you buy back on 4 December 2026 instead, 31 days after the sale. That is outside the 30 days, so the sale is matched with the pool.
| Proceeds: 1,000 × £7.00 | £7,000.00 |
| Cost from the pool: 1,000 × £5.00 | £5,000.00 |
| Gain | £2,000.00 |
| Pool after the sale: 1,000 shares | £5,000.00 |
| Pool after the buy-back joins it: 2,000 shares, £5.75 a share | £11,500.00 |
Either way you end up with 2,000 shares. What changes is the gain on this sale (£500 or £2,000) and the cost left in the pool for later sales (£10,000 or £11,500).
The free 30-day rule calculator matches your own buys and sales of one share in this order, with the same-day rule first and the section 104 pool last.
A worked example: buying and selling on the same day
Starting again from the same pool of 2,000 shares costing £10,000, on one day you buy 300 shares at £7.20 (£2,160) and sell 500 at £7.00 (£3,500). You buy none in the 30 days after.
| 300 matched with the same-day buy: £2,100.00 less £2,160.00 | −£60.00 |
| 200 matched with the pool: £1,400.00 less 200 × £5.00 | £400.00 |
| Gain on the sale | £340.00 |
| Pool afterwards: 1,800 shares, still £5.00 a share | £9,000.00 |
Both examples follow the order in HS284; its own example matches 500 of 4,000 shares sold with a purchase 12 days later and the other 3,500 with the section 104 holding.
What it means if you sell and buy back
- Within 30 days: the sale is matched with the buy-back, so the gain or loss is roughly the difference between the two prices, not between the sale price and what you first paid.
- After 30 days: the sale is matched with the pool, and the shares you buy back join the pool at their new price.
- The allowance: for 2026/27 the annual exempt amount is £3,000, and gains above it are taxed at 18% within your basic rate Income Tax band and 24% above it. The guide to capital gains tax on shares works through the whole sum.
This is information, not advice: check your own situation, and GOV.UK suggests getting help from HMRC or a professional if you need it.
Sources: GOV.UK, Capital Gains Tax rates and annual tax-free allowances, Capital Gains Tax rates and selling shares in the same company. Checked against GOV.UK on 15 November 2026.
ISAs and pensions
GOV.UK lists shares you have put into an ISA or PEP among those you do not pay Capital Gains Tax on when you dispose of them. HS284 and the Capital Gains Manual pages read for this guide do not say how a buy-back inside an ISA or a pension meets the 30-day rule, so this guide does not say either. If that is your case, check it with HMRC or a tax adviser.
Source: GOV.UK, Tax when you sell shares. Checked against GOV.UK on 15 November 2026.
How Divisio applies the rules
- The order. For each share, Divisio matches every sale with purchases made the same day, then with purchases in the 30 days after the sale (earlier sales first, and the earliest purchase first), then with the section 104 holding at its average cost. Purchases matched by the first two rules never join the pool.
- One day, one disposal. All sales of one share on one day are counted as one sale, and all its purchases on one day as one purchase.
- Costs. Fees and stamp duty from your broker's file are added to what a purchase cost and taken off what a sale made.
- Selling more than you hold. If you record selling more shares than your earlier purchases cover, the rest is matched with later purchases, earliest first.
- Accounts left out. Portfolios marked as an ISA, SIPP, Lifetime ISA or Junior ISA are left out, so a buy-back inside one of them is not matched with a sale in a general account.
- What it does not handle. It does not know whether you were resident in the UK when you bought, so it applies the 30-day rule to every purchase. It does not adjust for rights issues, bonus issues or takeovers. It matches by the share, so it treats all your general accounts as one person's holding.
The capital gains tax on shares page lists everything the estimate counts, and the demo shows the matching on two example portfolios with no sign-up.
Sources
- GOV.UK, HS284 Shares and Capital Gains Tax (2026), checked 15 November 2026.
- HMRC Capital Gains Manual, CG51560: the same day and bed and breakfast identification rules, checked 15 November 2026.
- HMRC Capital Gains Manual, CG13350: bed and breakfasting, checked 15 November 2026.
- GOV.UK, Tax when you sell shares and selling shares in the same company, checked 15 November 2026.
- GOV.UK, Capital Gains Tax rates and annual tax-free allowances and Capital Gains Tax rates, checked 15 November 2026.
The pool itself is explained in the section 104 holding guide.
Questions people ask
What is the 30-day rule for shares?
If you sell shares and buy shares of the same class in the same company in the 30 days after the sale, while UK resident, HMRC matches the sale with those new shares before your section 104 holding, so the gain is worked out against what the new shares cost (HS284).
Is the 30-day rule the same as bed and breakfasting?
Yes. HS284 calls the 30-day rule the bed and breakfasting rule, and HMRC's Capital Gains Manual says it was brought in in 1998 to counter selling shares and buying them back a short time later (CG51560 and CG13350).
Does the same day rule come before the 30-day rule?
Yes. HS284 matches a sale first with shares bought on the same day, then with shares bought in the next 30 days, then with the section 104 holding.
Does the 30-day rule apply if I was not resident in the UK?
HS284 says the bed and breakfasting rule does not apply if you were not resident in the UK for tax purposes when you bought the new shares.
What if I buy back more than 30 days later?
Then the sale is matched with your section 104 holding at its average cost, and the shares you buy back join the holding at their own cost.
See your own shares this way
Add what you own, from any broker, in a couple of minutes. Every feature is free during the beta, and no card is asked for. Or look round the demo first: two example portfolios, no sign-up.
For informational purposes only, not financial or tax advice. Tax rules depend on your own circumstances and can change; GOV.UK has the rules in full. Prices from Yahoo Finance, which can be delayed, usually by 15 minutes and on some exchanges by more.