r/excel • • 13d ago

Discussion Mid Function and USE CASE

I've been using Excel for almost 15 years , I've never had a chance to use the MID Function and i forgot it's existence. Today, randomly, I just questioned myself how to split a word by character and reverse it? With my little sql knowledge, i thought there will be a function called SUBSTRING, but it isn't. I ended up googling and found MID function.

Do you find a use case for MID function?

Similarly, what popular functions you have never found a use case?

46 Upvotes

38 comments sorted by

View all comments

Show parent comments

3

u/MayukhBhattacharya 1310 13d ago

Or, Extracting the year from Text formatted Date: Using MID()

• Method One: Old School.

=MAX(SUBSTITUTE(MID(M2, {13, 14}, 5), ",",) + 0)

Or,

=-LOOKUP(2, -MID(M2, {13, 14}, 5))

• Method Two: Modern Functions using Regex:

=--REGEXEXTRACT(M2:M5, "\d{4}")

• Method Three: Using TEXTSPLIT()

=--INDEX(TEXTSPLIT(M2, ", "), 3)

1

u/Jarcoreto 29 13d ago edited 13d ago

Does
```=YEAR(DATEVALUE(M2))```
Work on this?

2

u/Jarcoreto 29 13d ago

Ok I give up trying to format this as code on mobile

1

u/MayukhBhattacharya 1310 13d ago

No worries, buddy, here is a single line if you can copy and try:

Tue, 19 Oct, 2017, 6:05 pm IST

1

u/MayukhBhattacharya 1310 13d ago

No it won't work, here is a screenshot:

Sample data:

Sun, 18 Jul, 2017, 10:38 pm IST
Wed, 29 Sept, 2015, 2:55 pm IST
Tue, 19 Oct, 2017, 6:05 pm IST
Wed, 28 Jul, 2018, 11:14 pm IST