Extracting month from text

XcelLearner

Board Regular
Joined
Feb 6, 2016
Messages
52
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a (sample) data set with dates in text format in no particular order. They look like this:

4/10/2020
11/10/2020
10/10/2020
11/17/2020

They look like in date format, but they are texts. I would like to extract the number before the stroke "/" (that is month: April would be 4, not 04, and November should be 11.), so that the desired results should be (in number format):
4
11
10
11.

What is the possible formula(e)?
Thanks a lot.

tyEItxw.png
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Take a look at the excel functions LEFT and also FIND and combine the two
 
Upvote 0
Take a look at the excel functions LEFT and also FIND and combine the two
Actually, I've tried to combined LEFT and FIND, and even with SEARCH, but they kept giving me #Value errors. I might have used them incorrectly, these are functions that I've rarely used. Thanks.
 
Upvote 0
Do you mind if I ask, the "+0" is to make the result in number format?
Yes, I believe that is his intention.
If it is already a valid date entry, it won't hurt it anything. So it just covers both bases.

Out of curiosity, I did some testing on my side, and even with dates entered as text, this seemed to work without the "+0", i.e.
=MONTH(A2)

Not what I expected, but pleasantly surprised.
 
Upvote 0
N.B. The alternative below is relevant with Regional Settings International - dd-mm-yy.

T202012a.xlsm
AB
1Text Data
24/10/20204
311/10/2011
4
1a
Cell Formulas
RangeFormula
B2:B3B2=LEFT(A2,FIND("/",A2)-1)
 
Upvote 0
Yep. That's exactly right. +0 will convert a date stored as text to an Excel date. As Joe4 pointed out, it's not needed here, but I like to include it anywhere I'm referencing a date stored as text. Once you've been burned by a (date stored as text) < (date for comparison) comparative (where *all* dates stored as text would return "False"), you know why ;)
 
Upvote 0
As Joe4 pointed out, it's not needed here, but I like to include it anywhere I'm referencing a date stored as text. Once you've been burned by a (date stored as text) < (date for comparison) comparative (where *all* dates stored as text would return "False"), you know why
Yep, better safe than sorry!

I was actually a bit surprised that the MONTH function worked on a text entry. I would not have expected that.
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,812
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top