Nishaglobal Education logo

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.

Lesson 7 of 1240 minQuiz: 4 questions

🎯 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
  1. What you'll learn and why it matters
  2. Cleaning text
  3. Splitting and joining text
  4. Working with dates
  5. Practice
  6. Common mistakes
  7. Recap
  8. Quiz
  9. Mark lesson complete

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

TRIM removes extra spaces, PROPER capitalises each word, LOWER makes emails consistent. Functions can be combined: TRIM runs first, then PROPER.
RowABCDEF
1Name (messy)Clean nameEmail (messy)Clean emailCity (messy)Clean city
2 asha KUMAR Asha KumarAsha.Kumar@Example.comasha.kumar@example.compunePune
3ravi menonRavi Menonravi.menon@example.com ravi.menon@example.comChennaiChennai
4MEERA IYERMeera Iyermeera@example.commeera@example.com delhiDelhi
5kofi mensahKofi MensahKOFI.M@EXAMPLE.COMkofi.m@example.comAccraAccra
6Sara AliSara Alisara.ali@example.comsara.ali@example.comdubai 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
TRIM removes extra spaces, PROPER capitalises each word, LOWER makes emails consistent. Functions can be combined: TRIM runs first, then PROPER.
FunctionDoesExample result
TRIM(text)Removes spaces at the start and end, and double spaces insideasha KUMAR
PROPER(text)Capital first letter of each wordAsha Kumar
UPPER(text) / LOWER(text)All capitals / all small lettersasha.kumar@example.com
LEN(text)Number of characters10

Splitting and joining text

Worksheet: Text

FIND locates the space, LEFT and RIGHT take the parts before and after it, & joins text, and TEXTJOIN joins a whole range with a separator.
RowABCDEF
1Full nameFirst nameLast nameEmail userInitialsLabel
2Asha KumarAshaKumarasha.kumarAKKumar, Asha
3Ravi MenonRaviMenonravi.menonRMMenon, Ravi
4All first namesAsha, 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
FIND locates the space, LEFT and RIGHT take the parts before and after it, & joins text, and TEXTJOIN joins a whole range with a separator.
FunctionDoes
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 & bJoins 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

Adding 30 to a date gives the date 30 days later. EOMONTH gives the last day of the month; NETWORKDAYS counts Monday-to-Friday days between two dates, including both.
RowABCDEFGH
1InvoiceInvoice dateDue dateDays to payMonthYearMonth endWorking days
2INV-10112 Jan 202611 Feb 2026301202631 Jan 202623
3INV-10220 Feb 202622 Mar 2026302202628 Feb 202621

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
Adding 30 to a date gives the date 30 days later. EOMONTH gives the last day of the month; NETWORKDAYS counts Monday-to-Friday days between two dates, including both.
FunctionGives
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.

  1. In B2 type =PROPER(TRIM(A2)).
  2. Copy it down.
Show the solution

Worksheet: Names

RowAB
1NameClean
2 meera iyerMeera Iyer
3KOFI MENSAH Kofi Mensah
4sara aliSara 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

RowABCD
1StartEndCalendar daysWorking days
22 Mar 202631 Mar 20262922

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. 1. What does =TRIM(" Asha Kumar ") return?

  2. 2. Which formula joins B2 and C2 with a space between?

  3. 3. A2 holds 2026-01-10 and B2 holds 2026-01-25. What does =B2-A2 give?

  4. 4. What does =EOMONTH("2026-02-10",0) return?

Answer all 4 questions to check.

Mark this lesson complete

Finished this lesson?

When you have worked through the examples and exercises, mark it complete to save your progress.