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
"Extract the year, month, and day from an 8-digit date code like 20260215"
=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
- LEFT(text, num_chars) returns characters from the start
- MID(text, start_num, num_chars) returns characters from any position
- RIGHT(text, num_chars) returns characters from the end
- & concatenates the pieces with dash separators
- 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
"20260215"
2026-02-15
"=LEFT("Hello World", 5)"
Hello
"=MID("ABCDEF", 3, 2)"
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.