We’re improving Formula Genius. We’re redesigning the app and fixing issues along the way. Sorry for any disruption, and thank you for your patience.
Excel beginner

Excel LEFT, RIGHT, MID: Extract Text by Position

Pull characters from the start, end, or middle of text. Essential for parsing product codes, IDs, and fixed-format data.

Formula Genius can generate a draft from a plain-English prompt. Supported formulas can be checked with sample cases; review the coverage on the result.

The formula

Prompt

"Extract the year, month, and day from an 8-digit date code like 20260215"

Excel
=LEFT(A2, 4) & "-" & MID(A2, 5, 2) & "-" & RIGHT(A2, 2)

LEFT(A2, 4) grabs the first 4 characters (year). MID(A2, 5, 2) grabs 2 characters starting at position 5 (month). RIGHT(A2, 2) grabs the last 2 characters (day). Ampersands join them with dashes.

Step-by-step breakdown

  1. LEFT(text, num_chars) returns characters from the start
  2. MID(text, start_num, num_chars) returns characters from any position
  3. RIGHT(text, num_chars) returns characters from the end
  4. & concatenates the pieces with dash separators
  5. Result: '20260215' becomes '2026-02-15'

Edge cases & warnings

  • If num_chars exceeds the text length, the full text is returned (no error)
  • MID with start_num beyond text length returns empty string
  • These functions count characters, not bytes — emoji and accented characters count as 1
  • For dynamic extraction, combine with FIND or SEARCH to locate delimiters

Examples

Prompt

"20260215"

Excel
2026-02-15
Prompt

"=LEFT("Hello World", 5)"

Excel
Hello
Prompt

"=MID("ABCDEF", 3, 2)"

Excel
CD

Frequently asked questions

How do I extract text before a specific character?

Use LEFT with FIND: =LEFT(A2, FIND("-", A2)-1) extracts everything before the first dash.

What if the position varies?

Combine with FIND or SEARCH to locate characters dynamically. Example: =MID(A2, FIND("@", A2)+1, 100) extracts text after the @ sign.

Can't find what you need?

Describe a formula in plain English. Formula Genius drafts and explains it, and can check supported formulas on sample cases.