Cleaning text and working with dates
Tidy messy data with TRIM, PROPER, UPPER and LOWER, split and join text with LEFT, RIGHT, FIND and TEXTJOIN, and calculate with dates using TODAY, YEAR, MONTH, EOMONTH and NETWORKDAYS.
🎯 By the end of this lesson you will be able to:
- Clean messy text with TRIM, PROPER, UPPER and LOWER
- Split and join text with LEFT, RIGHT, LEN, FIND, & and TEXTJOIN
- Calculate with dates: differences, parts of dates, month ends and working days
Outline
What you'll learn and why it matters
Real data is messy: names in random capitals, extra spaces, emails in different cases, dates you need to group by month. Messy data breaks lookups and counts. These functions clean it in seconds instead of hours of retyping, and date maths answers questions like *how many working days until the deadline?*.
Cleaning text
Worksheet: Contacts
| Row | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
| 1 | Name (messy) | Clean name | Email (messy) | Clean email | City (messy) | Clean city |
| 2 | asha KUMAR | Asha Kumar | Asha.Kumar@Example.com | asha.kumar@example.com | pune | Pune |
| 3 | ravi menon | Ravi Menon | ravi.menon@example.com | ravi.menon@example.com | Chennai | Chennai |
| 4 | MEERA IYER | Meera Iyer | meera@example.com | meera@example.com | delhi | Delhi |
| 5 | kofi mensah | Kofi Mensah | KOFI.M@EXAMPLE.COM | kofi.m@example.com | Accra | Accra |
| 6 | Sara Ali | Sara Ali | sara.ali@example.com | sara.ali@example.com | dubai | Dubai |
Formulas (green cells)
- B2 =PROPER(TRIM(A2)) → Asha Kumar
- D2 =LOWER(TRIM(C2)) → asha.kumar@example.com
- F2 =PROPER(TRIM(E2)) → Pune
- B3 =PROPER(TRIM(A3)) → Ravi Menon
- D3 =LOWER(TRIM(C3)) → ravi.menon@example.com
- F3 =PROPER(TRIM(E3)) → Chennai
- B4 =PROPER(TRIM(A4)) → Meera Iyer
- D4 =LOWER(TRIM(C4)) → meera@example.com
- F4 =PROPER(TRIM(E4)) → Delhi
- B5 =PROPER(TRIM(A5)) → Kofi Mensah
- D5 =LOWER(TRIM(C5)) → kofi.m@example.com
- F5 =PROPER(TRIM(E5)) → Accra
- B6 =PROPER(TRIM(A6)) → Sara Ali
- D6 =LOWER(TRIM(C6)) → sara.ali@example.com
- F6 =PROPER(TRIM(E6)) → Dubai
| Function | Does | Example result |
|---|---|---|
TRIM(text) | Removes spaces at the start and end, and double spaces inside | asha KUMAR |
PROPER(text) | Capital first letter of each word | Asha Kumar |
UPPER(text) / LOWER(text) | All capitals / all small letters | asha.kumar@example.com |
LEN(text) | Number of characters | 10 |
Splitting and joining text
Worksheet: Text
| Row | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
| 1 | Full name | First name | Last name | Email user | Initials | Label |
| 2 | Asha Kumar | Asha | Kumar | asha.kumar | AK | Kumar, Asha |
| 3 | Ravi Menon | Ravi | Menon | ravi.menon | RM | Menon, Ravi |
| 4 | All first names | Asha, Ravi |
Formulas (green cells)
- B2 =LEFT(A2,FIND(" ",A2)-1) → Asha
- C2 =RIGHT(A2,LEN(A2)-FIND(" ",A2)) → Kumar
- D2 =LEFT("asha.kumar@example.com",FIND("@","asha.kumar@example.com")-1) → asha.kumar
- E2 =LEFT(B2,1)&LEFT(C2,1) → AK
- F2 =C2&", "&B2 → Kumar, Asha
- B3 =LEFT(A3,FIND(" ",A3)-1) → Ravi
- C3 =RIGHT(A3,LEN(A3)-FIND(" ",A3)) → Menon
- D3 =LEFT("ravi.menon@example.com",FIND("@","ravi.menon@example.com")-1) → ravi.menon
- E3 =LEFT(B3,1)&LEFT(C3,1) → RM
- F3 =C3&", "&B3 → Menon, Ravi
- B4 =TEXTJOIN(", ",TRUE,B2:B3) → Asha, Ravi
| Function | Does |
|---|---|
LEFT(text, n) / RIGHT(text, n) | The first / last n characters |
MID(text, start, n) | n characters from position start |
FIND(find, text) | The position of find inside text (case-sensitive) |
a & b | Joins text: =B2&" "&C2 |
TEXTJOIN(separator, TRUE, range) | Joins a range with a separator, skipping empty cells |
Working with dates
Excel stores a date as a number of days (1 January 1900 is day 1), so you can subtract dates and add days. Date functions pick dates apart and build new ones:
Worksheet: Dates
| Row | A | B | C | D | E | F | G | H |
|---|---|---|---|---|---|---|---|---|
| 1 | Invoice | Invoice date | Due date | Days to pay | Month | Year | Month end | Working days |
| 2 | INV-101 | 12 Jan 2026 | 11 Feb 2026 | 30 | 1 | 2026 | 31 Jan 2026 | 23 |
| 3 | INV-102 | 20 Feb 2026 | 22 Mar 2026 | 30 | 2 | 2026 | 28 Feb 2026 | 21 |
Formulas (green cells)
- C2 =B2+30 → 11 Feb 2026
- D2 =C2-B2 → 30
- E2 =MONTH(B2) → 1
- F2 =YEAR(B2) → 2026
- G2 =EOMONTH(B2,0) → 31 Jan 2026
- H2 =NETWORKDAYS(B2,C2) → 23
- C3 =B3+30 → 22 Mar 2026
- D3 =C3-B3 → 30
- E3 =MONTH(B3) → 2
- F3 =YEAR(B3) → 2026
- G3 =EOMONTH(B3,0) → 28 Feb 2026
- H3 =NETWORKDAYS(B3,C3) → 21
| Function | Gives |
|---|---|
TODAY() | Today's date (updates every day) |
DATE(2026, 3, 15) | A date from year, month and day |
YEAR(d), MONTH(d), DAY(d) | Parts of a date |
EOMONTH(d, 0) | The last day of d's month (1 = next month's end) |
NETWORKDAYS(start, end) | Working days (Mon to Fri) between two dates, inclusive |
TEXT(d, "mmm yyyy") | A date as text, such as Jan 2026, for labels |
If a subtraction shows a date instead of a number of days (such as *30 Jan 1900*), change the cell's format to Number or General.
Practice
Guided exercise
Tidy a name list
Clean the names in column A so each is in proper case with no extra spaces.
- In B2 type
=PROPER(TRIM(A2)). - Copy it down.
Show the solution
Worksheet: Names
| Row | A | B |
|---|---|---|
| 1 | Name | Clean |
| 2 | meera iyer | Meera Iyer |
| 3 | KOFI MENSAH | Kofi Mensah |
| 4 | sara ali | Sara Ali |
Formulas (green cells)
- B2 =PROPER(TRIM(A2)) → Meera Iyer
- B3 =PROPER(TRIM(A3)) → Kofi Mensah
- B4 =PROPER(TRIM(A4)) → Sara Ali
How to get there: TRIM also squashes double spaces inside the text into one, so KOFI MENSAH becomes KOFI MENSAH, and PROPER then gives Kofi Mensah.
Your turn
Days until the deadline
A project starts on 2026-03-02 and must finish by 2026-03-31. Work out the calendar days between them and the number of working days.
Show the solution
Worksheet: Deadline
| Row | A | B | C | D |
|---|---|---|---|---|
| 1 | Start | End | Calendar days | Working days |
| 2 | 2 Mar 2026 | 31 Mar 2026 | 29 | 22 |
Formulas (green cells)
- C2 =B2-A2 → 29
- D2 =NETWORKDAYS(A2,B2) → 22
How to get there: Subtracting dates gives days: 29. NETWORKDAYS counts weekdays including both the start and end dates: 22. Add a range of holiday dates as a third argument to skip public holidays too.
Common mistakes
Dates typed as text
You see: Sorting is wrong and date maths gives #VALUE!
Fix: Type dates as YYYY-MM-DD so Excel recognises them (they align right).
A date difference shown as a date
You see: You see 30 Jan 1900 instead of 30
Fix: Format the result as Number or General.
FIND is case-sensitive
You see: #VALUE! when the text is not found exactly
Fix: Use SEARCH for a case-insensitive search.
Overwriting the original data while cleaning
You see: No way to check or undo later
Fix: Clean into a new column first.
Recap
- TRIM, PROPER, UPPER and LOWER clean messy text; combine them, such as PROPER(TRIM(A2)).
- LEFT, RIGHT, MID, LEN and FIND split text; & and TEXTJOIN join it.
- Dates are numbers of days: subtract them, add days, and use YEAR, MONTH and EOMONTH.
- NETWORKDAYS counts working days; TODAY() gives the current date.
Key terms
- TRIM
- A function that removes extra spaces from text.
- Concatenate
- To join pieces of text together, with & or TEXTJOIN.
- Date serial number
- How Excel stores a date: the number of days since 1 January 1900.
Check your understanding
Answer all 4 questions, then check your answers to see an explanation for each one.
1. What does =TRIM(" Asha Kumar ") return?
2. Which formula joins B2 and C2 with a space between?
3. A2 holds 2026-01-10 and B2 holds 2026-01-25. What does =B2-A2 give?
4. What does =EOMONTH("2026-02-10",0) return?
Mark this lesson complete
Finished this lesson?
When you have worked through the examples and exercises, mark it complete to save your progress.