1. Home
  2. Guides
  3. Same-day and 30-day rules

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:

  1. Shares bought on the same day as the sale (the same day rule).
  2. 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.
  3. 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.

The sale, matched with the buy-back (30-day rule)
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.

The same sale, with the buy-back 31 days later
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.

One sale, matched by two rules
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

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 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

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.