Excel beginner LEFT RIGHT MID text extraction

Excel LEFT, RIGHT, MID: Extract Text by Position

LEFT, RIGHT, MID Functions is a Excel function that left(a2, 4) grabs the first 4 characters (year). Formula Genius generates and validates this formula automatically from a plain-English prompt.

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

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 any formula in plain English and Formula Genius will generate, explain, and validate it — instantly.